| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Proarrow.Optic.Fold
Description
The fold: the weakest read-side optic, reducing the foci to any Monoid object of the
category (FoldRes / foldMapP). It sits at the read-only top of the subtyping lattice --
everything that can view, preview or traverse is a fold -- so it has no builder of its own
(reach it by convert from a stronger optic). Its canonical eliminator is
foldMapOf, via the Forget carrier, with unfold as the re-mirror that
builds from a Comonoid seed.
Synopsis
- class (Profunctor p, Profunctor q) => FoldRes (p :: k +-> k) (q :: j +-> j) where
- type Fold (s :: k) (t :: j) (a :: k) (b :: j) = Optic (Prostrong (FoldRes :: (k +-> k) -> (j +-> j) -> Constraint)) s t a b
- data Forget (m :: k) (s :: k) (t :: j) where
- foldMapOf :: forall {j} {k} (c :: (k -> j -> Type) -> Constraint) (m :: k) (s :: k) (t :: j) (a :: k) (b :: j). (CategoryOf j, CategoryOf k, Ob m, c (Forget m :: k -> j -> Type)) => Optic c s t a b -> (a ~> m) -> s ~> m
- unfold :: forall {k} (c :: (OPPOSITE k -> OPPOSITE k -> Type) -> Constraint) (cm :: k) (s :: k) (t :: k) (a :: k) (b :: k). (Comonoid cm, Ob cm, forall (p :: OPPOSITE k +-> OPPOSITE k). c p => c (Op (UnOp p)), c (Forget ('OP cm) :: OPPOSITE k -> OPPOSITE k -> Type)) => Optic (OpConstraint c) s t a b -> (cm ~> b) -> cm ~> t
Documentation
class (Profunctor p, Profunctor q) => FoldRes (p :: k +-> k) (q :: j +-> j) where Source Github #
A fold is a getter or traversal that forgets everything except the ability to reduce the
a's it can see into any monoid object of k -- it can never reconstruct a t.
Methods
foldMapP :: forall (m :: k) (s :: k) (a :: k). Monoid m => p s a -> (a ~> m) -> s ~> m Source Github #
Instances
| (Bicartesian k, Traversable t, Representable t) => FoldRes (t :: k +-> k) (RepCostar t :: k -> k -> Type) Source Github # | |
| (CategoryOf k, CategoryOf j) => FoldRes (Id :: k -> k -> Type) (Id :: j -> j -> Type) Source Github # | |
| Monoidal k => FoldRes (Two :: k -> k -> Type) (CoTwo :: k -> k -> Type) Source Github # | |
| Monoidal k => FoldRes (UnitW :: k -> k -> Type) (CoUnitW :: k -> k -> Type) Source Github # | |
| HasInitialObject k => FoldRes (ZeroW :: k -> k -> Type) (CoZeroW :: k -> k -> Type) Source Github # | |
| (CategoryOf k, CategoryOf j) => FoldRes (Id :: k -> k -> Type) (TerminalProfunctor :: j -> j -> Type) Source Github # | |
| (Monoidal k, KnownNat n) => FoldRes (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
| Comonoid m => FoldRes (LensW m :: k -> k -> Type) (CoLensW m :: k -> k -> Type) Source Github # | |
| (CopyDiscard k, Ob a) => FoldRes (TensorW a :: k -> k -> Type) (CoTensorW a :: k -> k -> Type) Source Github # | |
| (Bicartesian k, Cotraversable t, Corepresentable t) => FoldRes (CorepStar t :: k -> k -> Type) (t :: k +-> k) Source Github # | The corepresentable-cotraversable witness folds by cotraversing at the fold profunctor |
| (FoldRes p1 q1, FoldRes p2 q2, Monoidal k) => FoldRes (Beside p1 p2 :: k -> k -> Type) (CoBeside q1 q2 :: k -> k -> Type) Source Github # | |
| (FoldRes p1 q1, FoldRes p2 q2, HasBinaryCoproducts k) => FoldRes (BesideSum p1 p2 :: k -> k -> Type) (CoBesideSum q1 q2 :: k -> k -> Type) Source Github # | |
| (HasCoproducts k, Ob t) => FoldRes (Corep (Coproduct t) :: k -> k -> Type) (Rep (Coproduct t) :: k -> k -> Type) Source Github # | |
| (CopyDiscard k, HasCoproducts k, Ob t) => FoldRes (Rep (Coproduct t) :: k -> k -> Type) (Corep (Coproduct t) :: k -> k -> Type) Source Github # | |
| (HasBinaryProducts k, Ob s) => FoldRes (Rep (Product s) :: k -> k -> Type) (Corep (Product s) :: k -> k -> Type) Source Github # | |
| (FoldRes f g, FoldRes f' g') => FoldRes (f :.: f' :: k -> k -> Type) (g' :.: g :: j -> j -> Type) Source Github # | |
type Fold (s :: k) (t :: j) (a :: k) (b :: j) = Optic (Prostrong (FoldRes :: (k +-> k) -> (j +-> j) -> Constraint)) s t a b Source Github #
data Forget (m :: k) (s :: k) (t :: j) where Source Github #
The carrier profunctor for foldMapOf: a generalized s -> m (the Forget of the
optics library).
Constructors
| Forget | |
Instances
| (CategoryOf j, Monoid m, SubFlavor w (FoldRes :: (k +-> k) -> (j +-> j) -> Constraint)) => Prostrong (w :: FLAVOR j k) (Forget m :: k -> j -> Type) Source Github # | Any flavor whose optics can fold has strength for the |
| (CategoryOf j, CategoryOf k, Ob m) => Profunctor (Forget m :: k -> j -> Type) Source Github # | |
Defined in Proarrow.Optic.Fold Methods dimap :: forall (c :: k) (a :: k) (b :: j) (d :: j). (c ~> a) -> (b ~> d) -> Forget m a b -> Forget m c d Source Github # lmap :: forall (c :: k) (a :: k) (b :: j). (c ~> a) -> Forget m a b -> Forget m c b Source Github # rmap :: forall (b :: j) (d :: j) (a :: k). (b ~> d) -> Forget m a b -> Forget m a d Source Github # (\\) :: forall (a :: k) (b :: j) r. ((Ob a, Ob b) => r) -> Forget m a b -> r Source Github # | |
foldMapOf :: forall {j} {k} (c :: (k -> j -> Type) -> Constraint) (m :: k) (s :: k) (t :: j) (a :: k) (b :: j). (CategoryOf j, CategoryOf k, Ob m, c (Forget m :: k -> j -> Type)) => Optic c s t a b -> (a ~> m) -> s ~> m Source Github #
Fold through any optic that can act as a fold, in either encoding.
unfold :: forall {k} (c :: (OPPOSITE k -> OPPOSITE k -> Type) -> Constraint) (cm :: k) (s :: k) (t :: k) (a :: k) (b :: k). (Comonoid cm, Ob cm, forall (p :: OPPOSITE k +-> OPPOSITE k). c p => c (Op (UnOp p)), c (Forget ('OP cm) :: OPPOSITE k -> OPPOSITE k -> Type)) => Optic (OpConstraint c) s t a b -> (cm ~> b) -> cm ~> t Source Github #