| 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 (AffineTravRes).
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 MatchP carrier.
Synopsis
- distLP :: forall k (a :: k) (b :: k) (c :: k). (Distributive k, Ob a, Ob b, Ob c, TensorIsProduct a (b || c), TensorIsProduct a b, TensorIsProduct a c) => (a && (b || c)) ~> ((a && b) || (a && c))
- distRP :: forall k (a :: k) (b :: k) (c :: k). (Distributive k, Ob a, Ob b, Ob c, TensorIsProduct (a || b) c, TensorIsProduct a c, TensorIsProduct b c) => ((a || b) && c) ~> ((a && c) || (b && c))
- class (TravRes p q, AffineFoldRes p q) => AffineTravRes (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 (AffineTravRes :: (k +-> k) -> (k +-> k) -> Constraint)) s t a b
- type AffineTraversal' (s :: k) (a :: k) = AffineTraversal s s a a
- data MatchP (a :: k) (s :: k) (t :: k) where
- matching :: forall {k} (c :: (k -> k -> Type) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k). (Bicartesian k, c (MatchP a)) => Optic c s t a b -> s ~> (t || a)
Documentation
distLP :: forall k (a :: k) (b :: k) (c :: k). (Distributive k, Ob a, Ob b, Ob c, TensorIsProduct a (b || c), TensorIsProduct a b, TensorIsProduct a c) => (a && (b || c)) ~> ((a && b) || (a && c)) Source Github #
distLdistR are stated in terms of **, which is only equal/ to && under
Cartesian rather than reducing to it, and that equality doesn't propagate through the
non-injective || automatically. Forcing TensorIsProduct to be solved at each component
(rather than relying on the quantified constraint Cartesian provides to fire implicitly)
materializes the equalities as givens so they rewrite inside || too.
distRP :: forall k (a :: k) (b :: k) (c :: k). (Distributive k, Ob a, Ob b, Ob c, TensorIsProduct (a || b) c, TensorIsProduct a c, TensorIsProduct b c) => ((a || b) && c) ~> ((a && c) || (b && c)) Source Github #
class (TravRes p q, AffineFoldRes p q) => AffineTravRes (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 => AffineTravRes (Id :: k -> k -> Type) (Id :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.AffineTraversal | |
| (CopyDiscard k, HasCoproducts k, Ob t) => AffineTravRes (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) => AffineTravRes (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 # | |
| (AffineTravRes f g, AffineTravRes f' g') => AffineTravRes (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 (AffineTravRes :: (k +-> k) -> (k +-> k) -> Constraint)) s t a b Source Github #
type AffineTraversal' (s :: k) (a :: k) = AffineTraversal s s a a Source Github #
data MatchP (a :: k) (s :: k) (t :: k) where Source Github #
The eliminating carrier for matching: an affine traversal's match leg s ,
as a profunctor in ~> (t || a)s/t.
Constructors
| MatchP | |
Instances
| (Bicartesian k, Ob a, SubFlavor w (AffineTravRes :: (k +-> k) -> (k +-> k) -> Constraint)) => Prostrong (w :: FLAVOR k k) (MatchP a :: k -> k -> Type) Source Github # | Any flavor whose optics can match has strength for the |
Defined in Proarrow.Optic.AffineTraversal | |
| (HasBinaryCoproducts k, Ob a) => Profunctor (MatchP a :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.AffineTraversal Methods dimap :: forall (c :: k) (a0 :: k) (b :: k) (d :: k). (c ~> a0) -> (b ~> d) -> MatchP a a0 b -> MatchP a c d Source Github # lmap :: forall (c :: k) (a0 :: k) (b :: k). (c ~> a0) -> MatchP a a0 b -> MatchP a c b Source Github # rmap :: forall (b :: k) (d :: k) (a0 :: k). (b ~> d) -> MatchP a a0 b -> MatchP a a0 d Source Github # (\\) :: forall (a0 :: k) (b :: k) r. ((Ob a0, Ob b) => r) -> MatchP a a0 b -> r Source Github # | |
matching :: forall {k} (c :: (k -> k -> Type) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k). (Bicartesian k, c (MatchP a)) => 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).