proarrow
Safe HaskellNone
LanguageGHC2024

Proarrow.Optic.TensorOps

Description

Carrier-based optic operations. Input and output constraints may differ: an operation preserves a flavor when its carriers support that flavor, and may weaken it when the operation introduces additional structure. No optic is converted through its existential representation by these combinators.

Give the result a named optic type when choosing its flavor, for example:

paired :: Lens ((Bool, Bool), Bool) ((Bool, Bool), Bool) (Bool, Bool) (Bool, Bool)
paired = tensorOptic firstField negationIso

Here the first input is a lens and the second an iso, while the result stays a lens. Their flavor modules supply the carrier instances; this module owns only the operations and carriers. In particular it never chooses a flavor at runtime or weakens an optic via convert.

Synopsis

Documentation

firstOptic :: forall {k} (u :: k) (v :: k) (input :: (k +-> k) -> Constraint) (output :: (k +-> k) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k). (Monoidal k, Ob u, Ob v, forall (p :: k +-> k). (output p, Profunctor p) => input (TensorRight p u v)) => Optic input s t a b -> Optic output (s ** u) (t ** v) (a ** u) (b ** v) Source Github #

Carry independent forward and backward wires alongside an optic.

data TensorRight (p :: k +-> k) (u :: k) (v :: k) (a :: k) (b :: k) where Source Github #

Constructors

TensorRight :: forall {k} (p :: k +-> k) (u :: k) (v :: k) (a :: k) (b :: k). (Ob a, Ob b) => p (a ** u) (b ** v) -> TensorRight p u v a b 

Instances

Instances details
(Monoidal k, Profunctor p, Ob u, Ob v) => Prostrong (IsoFl :: (k +-> k) -> (k +-> k) -> Constraint) (TensorRight p u v :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Iso

Methods

proact :: forall (f :: k +-> k) (g :: k +-> k). (IsoFl f g, Profunctor f, Profunctor g) => ((f :.: TensorRight p u v) :.: g) :~> TensorRight p u v Source Github #

(Cartesian k, Prostrong (LensFl :: (k +-> k) -> (k +-> k) -> Constraint) p, Ob u, Ob v) => Prostrong (LensFl :: (k +-> k) -> (k +-> k) -> Constraint) (TensorRight p u v :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Lens

Methods

proact :: forall (f :: k +-> k) (g :: k +-> k). (LensFl f g, Profunctor f, Profunctor g) => ((f :.: TensorRight p u v) :.: g) :~> TensorRight p u v Source Github #

(SymMonoidal k, Prostrong (MonLensFl :: (k +-> k) -> (k +-> k) -> Constraint) p, Ob c, Ob d) => Prostrong (MonLensFl :: (k +-> k) -> (k +-> k) -> Constraint) (TensorRight p c d :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.MonoidalLens

Methods

proact :: forall (f :: k +-> k) (g :: k +-> k). (MonLensFl f g, Profunctor f, Profunctor g) => ((f :.: TensorRight p c d) :.: g) :~> TensorRight p c d Source Github #

(Monoidal k, Prostrong (GetterFl :: (k +-> k) -> (k +-> k) -> Constraint) p, Ob u, Ob v) => Prostrong (GetterFl :: (k +-> k) -> (k +-> k) -> Constraint) (TensorRight p u v :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Getter

Methods

proact :: forall (f :: k +-> k) (g :: k +-> k). (GetterFl f g, Profunctor f, Profunctor g) => ((f :.: TensorRight p u v) :.: g) :~> TensorRight p u v Source Github #

(Monoidal k, Prostrong (ActFl (Tensor :: k -> (k, k) -> Type)) p, Ob u, Ob v) => Prostrong (ActFl (Tensor :: k -> (k, k) -> Type) :: (k +-> k) -> (k +-> k) -> Constraint) (TensorRight p u v :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Action

Methods

proact :: forall (f :: k +-> k) (g :: k +-> k). (ActFl (Tensor :: k -> (k, k) -> Type) f g, Profunctor f, Profunctor g) => ((f :.: TensorRight p u v) :.: g) :~> TensorRight p u v Source Github #

(Monoidal k, Profunctor p, Ob u, Ob v) => Profunctor (TensorRight p u v :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.TensorOps

Methods

dimap :: forall (c :: k) (a :: k) (b :: k) (d :: k). (c ~> a) -> (b ~> d) -> TensorRight p u v a b -> TensorRight p u v c d Source Github #

lmap :: forall (c :: k) (a :: k) (b :: k). (c ~> a) -> TensorRight p u v a b -> TensorRight p u v c b Source Github #

rmap :: forall (b :: k) (d :: k) (a :: k). (b ~> d) -> TensorRight p u v a b -> TensorRight p u v a d Source Github #

(\\) :: forall (a :: k) (b :: k) r. ((Ob a, Ob b) => r) -> TensorRight p u v a b -> r Source Github #

tensorOptic :: forall {k} (input1 :: (k +-> k) -> Constraint) (input2 :: (k +-> k) -> Constraint) (output :: (k +-> k) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k) (u :: k) (v :: k) (c :: k) (d :: k). (SymMonoidal k, forall (p :: k +-> k). (output p, Profunctor p) => input1 (TensorRight p u v), forall (p :: k +-> k). (output p, Profunctor p) => input2 (TensorRight p a b)) => Optic input1 s t a b -> Optic input2 u v c d -> Optic output (s ** u) (t ** v) (a ** c) (b ** d) Source Github #

Tensor optics, allowing the inputs to have different flavors.

strengthBackward :: forall {k} (m :: k) (input :: (k +-> k) -> Constraint) (output :: (k +-> k) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k). (Monoidal k, Ob m, forall (p :: k +-> k). (output p, Profunctor p) => input (Backward p m)) => Optic input s t a b -> Optic output s (m ** t) a (m ** b) Source Github #

Carry an extra value along just the backward wire.

data Backward (p :: k +-> k) (m :: k) (a :: k) (b :: k) where Source Github #

Constructors

Backward :: forall {k} (p :: k +-> k) (m :: k) (a :: k) (b :: k). (Ob a, Ob b) => p a (m ** b) -> Backward p m a b 

Instances

Instances details
(Monoidal k, Profunctor p, Ob m) => Prostrong (IsoFl :: (k +-> k) -> (k +-> k) -> Constraint) (Backward p m :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Iso

Methods

proact :: forall (f :: k +-> k) (g :: k +-> k). (IsoFl f g, Profunctor f, Profunctor g) => ((f :.: Backward p m) :.: g) :~> Backward p m Source Github #

(Cartesian k, Prostrong (LensFl :: (k +-> k) -> (k +-> k) -> Constraint) p, Ob m) => Prostrong (LensFl :: (k +-> k) -> (k +-> k) -> Constraint) (Backward p m :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Lens

Methods

proact :: forall (f :: k +-> k) (g :: k +-> k). (LensFl f g, Profunctor f, Profunctor g) => ((f :.: Backward p m) :.: g) :~> Backward p m Source Github #

(SymMonoidal k, Prostrong (MonLensFl :: (k +-> k) -> (k +-> k) -> Constraint) p, Ob m) => Prostrong (MonLensFl :: (k +-> k) -> (k +-> k) -> Constraint) (Backward p m :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.MonoidalLens

Methods

proact :: forall (f :: k +-> k) (g :: k +-> k). (MonLensFl f g, Profunctor f, Profunctor g) => ((f :.: Backward p m) :.: g) :~> Backward p m Source Github #

(Monoidal k, Prostrong (GetterFl :: (k +-> k) -> (k +-> k) -> Constraint) p, Ob m) => Prostrong (GetterFl :: (k +-> k) -> (k +-> k) -> Constraint) (Backward p m :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Getter

Methods

proact :: forall (f :: k +-> k) (g :: k +-> k). (GetterFl f g, Profunctor f, Profunctor g) => ((f :.: Backward p m) :.: g) :~> Backward p m Source Github #

(Monoidal k, Profunctor p, Ob m) => Profunctor (Backward p m :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.TensorOps

Methods

dimap :: forall (c :: k) (a :: k) (b :: k) (d :: k). (c ~> a) -> (b ~> d) -> Backward p m a b -> Backward p m c d Source Github #

lmap :: forall (c :: k) (a :: k) (b :: k). (c ~> a) -> Backward p m a b -> Backward p m c b Source Github #

rmap :: forall (b :: k) (d :: k) (a :: k). (b ~> d) -> Backward p m a b -> Backward p m a d Source Github #

(\\) :: forall (a :: k) (b :: k) r. ((Ob a, Ob b) => r) -> Backward p m a b -> r Source Github #

(SymMonoidal k, Prostrong (ActFl (Tensor :: k -> (k, k) -> Type)) p, Ob m) => Prostrong (ActFl (Tensor :: k -> (k, k) -> Type) :: (k +-> k) -> (k +-> k) -> Constraint) (Backward p m :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Action

Methods

proact :: forall (f :: k +-> k) (g :: k +-> k). (ActFl (Tensor :: k -> (k, k) -> Type) f g, Profunctor f, Profunctor g) => ((f :.: Backward p m) :.: g) :~> Backward p m Source Github #

mapContinuation :: forall {k} (input :: (k -> k -> Type) -> Constraint) (output :: (k +-> k) -> Constraint) (s :: k) (x :: k) (y :: k) (r :: k) (z :: k) (t :: k). (CategoryOf k, input (Continuation output s x)) => Optic input y r z t -> Optic output s t x z -> Optic output s r x y Source Github #

Plug an optic into the backward focus of another optic. The downstream optic is interpreted directly at the continuation carrier of the output.

data Continuation (output :: (k +-> k) -> Constraint) (s :: k) (x :: k) (a :: k) (b :: k) where Source Github #

Constructors

Continuation :: forall {k} (a :: k) (b :: k) (output :: (k +-> k) -> Constraint) (s :: k) (x :: k). (Ob a, Ob b) => Optic output s b x a -> Continuation output s x a b 

Instances

Instances details
(CategoryOf k, Ob s, Ob x) => Prostrong (IsoFl :: (k +-> k) -> (k +-> k) -> Constraint) (Continuation output s x :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Iso

Methods

proact :: forall (f :: k +-> k) (g :: k +-> k). (IsoFl f g, Profunctor f, Profunctor g) => ((f :.: Continuation output s x) :.: g) :~> Continuation output s x Source Github #

(Cartesian k, Ob s, Ob x, forall (m :: k) (p :: k +-> k). (Ob m, output p, Profunctor p) => output (Backward p m)) => Prostrong (LensFl :: (k +-> k) -> (k +-> k) -> Constraint) (Continuation output s x :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Lens

Methods

proact :: forall (f :: k +-> k) (g :: k +-> k). (LensFl f g, Profunctor f, Profunctor g) => ((f :.: Continuation output s x) :.: g) :~> Continuation output s x Source Github #

(SymMonoidal k, Ob s, Ob x, forall (m :: k) (p :: k +-> k). (Ob m, output p, Profunctor p) => output (Backward p m)) => Prostrong (MonLensFl :: (k +-> k) -> (k +-> k) -> Constraint) (Continuation output s x :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.MonoidalLens

Methods

proact :: forall (f :: k +-> k) (g :: k +-> k). (MonLensFl f g, Profunctor f, Profunctor g) => ((f :.: Continuation output s x) :.: g) :~> Continuation output s x Source Github #

(CategoryOf k, Ob s, Ob x) => Prostrong (GetterFl :: (k +-> k) -> (k +-> k) -> Constraint) (Continuation (Prostrong (GetterFl :: (k +-> k) -> (k +-> k) -> Constraint)) s x :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Getter

Methods

proact :: forall (f :: k +-> k) (g :: k +-> k). (GetterFl f g, Profunctor f, Profunctor g) => ((f :.: Continuation (Prostrong (GetterFl :: (k +-> k) -> (k +-> k) -> Constraint)) s x) :.: g) :~> Continuation (Prostrong (GetterFl :: (k +-> k) -> (k +-> k) -> Constraint)) s x Source Github #

(Monoidal k, Ob s, Ob x, forall (m :: k) (p :: k +-> k). (Ob m, output p, Profunctor p) => output (Backward p m)) => Prostrong (ActFl (Tensor :: k -> (k, k) -> Type) :: (k +-> k) -> (k +-> k) -> Constraint) (Continuation output s x :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Action

Methods

proact :: forall (f :: k +-> k) (g :: k +-> k). (ActFl (Tensor :: k -> (k, k) -> Type) f g, Profunctor f, Profunctor g) => ((f :.: Continuation output s x) :.: g) :~> Continuation output s x Source Github #

(CategoryOf k, Ob s, Ob x) => Profunctor (Continuation output s x :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.TensorOps

Methods

dimap :: forall (c :: k) (a :: k) (b :: k) (d :: k). (c ~> a) -> (b ~> d) -> Continuation output s x a b -> Continuation output s x c d Source Github #

lmap :: forall (c :: k) (a :: k) (b :: k). (c ~> a) -> Continuation output s x a b -> Continuation output s x c b Source Github #

rmap :: forall (b :: k) (d :: k) (a :: k). (b ~> d) -> Continuation output s x a b -> Continuation output s x a d Source Github #

(\\) :: forall (a :: k) (b :: k) r. ((Ob a, Ob b) => r) -> Continuation output s x a b -> r Source Github #

retainView :: forall {k} (w :: (k -> k -> Type) -> (k -> k -> Type) -> Constraint) (input :: (k +-> k) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k). (Comonoid a, w (Rep (ActionAt (Tensor :: k -> (k, k) -> Type) a)) (Corep (ActionAt (Tensor :: k -> (k, k) -> Type) a)), forall (p :: k +-> k). (Prostrong w p, Profunctor p) => input (Backward p a)) => Optic input s t a b -> Optic (Prostrong w) s (a ** t) a b Source Github #

Retain the sampled focus alongside the backward result. The output flavor must admit the copying witness; an iso may therefore produce a lens here.