| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Proarrow.Optic.AffineFold
Description
The affine fold: a fold that sees at most one focus, s
(~> (a || TerminalObject)AffineFoldRes / previewP). Every Getter and
AffineTraversal is one, and it subtypes to
Fold. Like all read-only flavors it has no builder of its own
(convert a stronger optic); its canonical eliminator is preview / (^?),
via the PreviewP carrier.
Synopsis
- class FoldRes p q => AffineFoldRes (p :: k +-> k) (q :: j +-> j) where
- previewP :: forall (s :: k) (a :: k). Bicartesian k => p s a -> s ~> (a || (TerminalObject :: k))
- type AffineFold (s :: k) (t :: j) (a :: k) (b :: j) = Optic (Prostrong (AffineFoldRes :: (k +-> k) -> (j +-> j) -> Constraint)) s t a b
- data PreviewP (a :: k) (s :: k) (t :: j) where
- preview :: forall {j} {k} (c :: (k -> j -> Type) -> Constraint) (s :: k) (t :: j) (a :: k) (b :: j). (Bicartesian k, CategoryOf j, c (PreviewP a :: k -> j -> Type)) => Optic c s t a b -> s ~> (a || (TerminalObject :: k))
- (^?) :: forall s t a b (c :: (Type -> Type -> Type) -> Constraint). c (PreviewP a :: Type -> Type -> Type) => s -> Optic c s t a b -> Maybe a
Documentation
class FoldRes p q => AffineFoldRes (p :: k +-> k) (q :: j +-> j) where Source Github #
An affine fold is a fold that can see at most one a -- 0-or-1, never 0-or-many. A getter
is an affine fold that always succeeds; an affine traversal is one that additionally knows how
to reconstruct a t when it fails to match.
Methods
previewP :: forall (s :: k) (a :: k). Bicartesian k => p s a -> s ~> (a || (TerminalObject :: k)) Source Github #
Instances
type AffineFold (s :: k) (t :: j) (a :: k) (b :: j) = Optic (Prostrong (AffineFoldRes :: (k +-> k) -> (j +-> j) -> Constraint)) s t a b Source Github #
data PreviewP (a :: k) (s :: k) (t :: j) where Source Github #
The carrier profunctor for preview: a generalized s -> Maybe a.
Constructors
| PreviewP | |
Fields
| |
Instances
| (Bicartesian k, CategoryOf j, Ob a, SubFlavor w (AffineFoldRes :: (k +-> k) -> (j +-> j) -> Constraint)) => Prostrong (w :: FLAVOR j k) (PreviewP a :: k -> j -> Type) Source Github # | Any flavor whose optics can preview has strength for the |
| (Bicartesian k, CategoryOf j, Ob a) => Profunctor (PreviewP a :: k -> j -> Type) Source Github # | |
Defined in Proarrow.Optic.AffineFold Methods dimap :: forall (c :: k) (a0 :: k) (b :: j) (d :: j). (c ~> a0) -> (b ~> d) -> PreviewP a a0 b -> PreviewP a c d Source Github # lmap :: forall (c :: k) (a0 :: k) (b :: j). (c ~> a0) -> PreviewP a a0 b -> PreviewP a c b Source Github # rmap :: forall (b :: j) (d :: j) (a0 :: k). (b ~> d) -> PreviewP a a0 b -> PreviewP a a0 d Source Github # (\\) :: forall (a0 :: k) (b :: j) r. ((Ob a0, Ob b) => r) -> PreviewP a a0 b -> r Source Github # | |
preview :: forall {j} {k} (c :: (k -> j -> Type) -> Constraint) (s :: k) (t :: j) (a :: k) (b :: j). (Bicartesian k, CategoryOf j, c (PreviewP a :: k -> j -> Type)) => Optic c s t a b -> s ~> (a || (TerminalObject :: k)) Source Github #
Preview through any optic that can act as an affine fold, in either encoding.