| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Proarrow.Optic.AffineTraversal
Description
The affine traversal: the 0-or-1 focus optic that can also reconstruct, the meet of
Lens and Prism in the subtyping lattice. Its two
legs are affineMatch :: s ~> (t || a) and affineSet :: (s && b) ~> t (AffineTravFl).
Its witnesses only ever arise by composing lens and prism witnesses, so it is built with
affineTraversal (a Lens followed by a
Prism) and eliminated with matching, via the generic
ExOptic carrier.
Synopsis
- class (TravFl p q, AffineFoldFl p q) => AffineTravFl (p :: k +-> k) (q :: k +-> k) where
- affineMatch :: forall (s :: k) (a :: k) (b :: k) (t :: k). Bicartesian k => p s a -> q b t -> s ~> (t || a)
- affineSet :: forall (s :: k) (a :: k) (b :: k) (t :: k). Bicartesian k => p s a -> q b t -> (s && b) ~> t
- type AffineTraversal (s :: k) (t :: k) (a :: k) (b :: k) = Optic (Prostrong (AffineTravFl :: (k +-> k) -> (k +-> k) -> Constraint)) s t a b
- type AffineTraversal' (s :: k) (a :: k) = AffineTraversal s s a a
- matching :: forall {k} (c :: (k -> k -> Type) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k). (Bicartesian k, (Ob a, Ob b) => c (ExOptic (AffineTravFl :: (k +-> k) -> (k +-> k) -> Constraint) a b)) => Optic c s t a b -> s ~> (t || a)
Documentation
class (TravFl p q, AffineFoldFl p q) => AffineTravFl (p :: k +-> k) (q :: k +-> k) where Source Github #
Methods
affineMatch :: forall (s :: k) (a :: k) (b :: k) (t :: k). Bicartesian k => p s a -> q b t -> s ~> (t || a) Source Github #
affineSet :: forall (s :: k) (a :: k) (b :: k) (t :: k). Bicartesian k => p s a -> q b t -> (s && b) ~> t Source Github #
Instances
| CategoryOf k => AffineTravFl (Id :: k -> k -> Type) (Id :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.AffineTraversal | |
| Comonoid m => AffineTravFl (Rep (ActionAt (Tensor :: k -> (k, k) -> Type) m) :: k -> k -> Type) (Corep (ActionAt (Tensor :: k -> (k, k) -> Type) m) :: k -> k -> Type) Source Github # | In a cartesian category the tensor is the product, so the comonoidal residual can be
projected out and put back: |
Defined in Proarrow.Optic.MonoidalLens Methods affineMatch :: forall (s :: k) (a :: k) (b :: k) (t :: k). Bicartesian k => Rep (ActionAt (Tensor :: k -> (k, k) -> Type) m) s a -> Corep (ActionAt (Tensor :: k -> (k, k) -> Type) m) b t -> s ~> (t || a) Source Github # affineSet :: forall (s :: k) (a :: k) (b :: k) (t :: k). Bicartesian k => Rep (ActionAt (Tensor :: k -> (k, k) -> Type) m) s a -> Corep (ActionAt (Tensor :: k -> (k, k) -> Type) m) b t -> (s && b) ~> t Source Github # | |
| (CopyDiscard k, HasCoproducts k, Ob t) => AffineTravFl (Rep (Coproduct t) :: k -> k -> Type) (Corep (Coproduct t) :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.AffineTraversal Methods affineMatch :: forall (s :: k) (a :: k) (b :: k) (t0 :: k). Bicartesian k => Rep (Coproduct t) s a -> Corep (Coproduct t) b t0 -> s ~> (t0 || a) Source Github # affineSet :: forall (s :: k) (a :: k) (b :: k) (t0 :: k). Bicartesian k => Rep (Coproduct t) s a -> Corep (Coproduct t) b t0 -> (s && b) ~> t0 Source Github # | |
| (HasBinaryProducts k, Ob s) => AffineTravFl (Rep (Product s) :: k -> k -> Type) (Corep (Product s) :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.AffineTraversal Methods affineMatch :: forall (s0 :: k) (a :: k) (b :: k) (t :: k). Bicartesian k => Rep (Product s) s0 a -> Corep (Product s) b t -> s0 ~> (t || a) Source Github # affineSet :: forall (s0 :: k) (a :: k) (b :: k) (t :: k). Bicartesian k => Rep (Product s) s0 a -> Corep (Product s) b t -> (s0 && b) ~> t Source Github # | |
| (AffineTravFl f g, AffineTravFl f' g') => AffineTravFl (f :.: f' :: i -> i -> Type) (g' :.: g :: i -> i -> Type) Source Github # | |
Defined in Proarrow.Optic.AffineTraversal | |
type AffineTraversal (s :: k) (t :: k) (a :: k) (b :: k) = Optic (Prostrong (AffineTravFl :: (k +-> k) -> (k +-> k) -> Constraint)) s t a b Source Github #
type AffineTraversal' (s :: k) (a :: k) = AffineTraversal s s a a Source Github #
matching :: forall {k} (c :: (k -> k -> Type) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k). (Bicartesian k, (Ob a, Ob b) => c (ExOptic (AffineTravFl :: (k +-> k) -> (k +-> k) -> Constraint) a b)) => Optic c s t a b -> s ~> (t || a) Source Github #
Match through any optic that can act as an affine traversal, in either encoding: returns the
focus () when it matches, or a reconstructed rgtt () when it does not. This is the
lftAffineTraversal eliminator, refining preview (which forgets t).
Runs the optic at its witness pair (ExOptic AffineTravFl, via withLegs) and applies
affineMatch.