| 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 (FoldFl / 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 generic ExOptic carrier, with unfold as the re-mirror that
builds from a Comonoid seed.
Synopsis
- class (Profunctor p, Profunctor q) => FoldFl (p :: k +-> k) (q :: j +-> j) where
- type Fold (s :: k) (t :: j) (a :: k) (b :: j) = Optic (Prostrong (FoldFl :: (k +-> k) -> (j +-> j) -> Constraint)) s t a b
- 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, Monoid m, (Ob a, Ob b) => c (ExOptic (FoldFl :: (k +-> k) -> (j +-> j) -> Constraint) a b)) => 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)), (Ob a, Ob b) => c (ExOptic (FoldFl :: (OPPOSITE k +-> OPPOSITE k) -> (OPPOSITE k +-> OPPOSITE k) -> Constraint) ('OP b) ('OP a))) => Optic (OpConstraint c) s t a b -> (cm ~> b) -> cm ~> t
Documentation
class (Profunctor p, Profunctor q) => FoldFl (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
| (Distributive k, CopyDiscard k, Traversable t, Representable t) => FoldFl (t :: k +-> k) (RepCostar t :: k -> k -> Type) Source Github # | |
| (CategoryOf k, CategoryOf j) => FoldFl (Id :: k -> k -> Type) (Id :: j -> j -> Type) Source Github # | |
| Monoidal k => FoldFl (UnitW :: k -> k -> Type) (CoUnitW :: k -> k -> Type) Source Github # | |
| HasInitialObject k => FoldFl (ZeroW :: k -> k -> Type) (CoZeroW :: k -> k -> Type) Source Github # | |
| (CategoryOf k, CategoryOf j) => FoldFl (Id :: k -> k -> Type) (TerminalProfunctor :: j -> j -> Type) Source Github # | |
| (Monoidal k, SNatI n) => FoldFl (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
| (Distributive k, CopyDiscard k, Cotraversable t, Corepresentable t) => FoldFl (CorepStar t :: k -> k -> Type) (t :: k +-> k) Source Github # | The corepresentable-cotraversable witness folds by cotraversing at the fold profunctor
|
| (FoldFl p1 q1, FoldFl p2 q2, Monoidal k) => FoldFl (Beside p1 p2 :: k -> k -> Type) (CoBeside q1 q2 :: k -> k -> Type) Source Github # | |
| (FoldFl p1 q1, FoldFl p2 q2, HasBinaryCoproducts k) => FoldFl (BesideSum p1 p2 :: k -> k -> Type) (CoBesideSum q1 q2 :: k -> k -> Type) Source Github # | |
| (HasCoproducts k, Ob t) => FoldFl (Corep (Coproduct t) :: k -> k -> Type) (Rep (Coproduct t) :: k -> k -> Type) Source Github # | |
| Comonoid m => FoldFl (Rep (ActionAt (Tensor :: k -> (k, k) -> Type) m) :: k -> k -> Type) (Corep (ActionAt (Tensor :: k -> (k, k) -> Type) m) :: k -> k -> Type) Source Github # | The tensor-action witness pair |
| (CopyDiscard k, HasCoproducts k, Ob t) => FoldFl (Rep (Coproduct t) :: k -> k -> Type) (Corep (Coproduct t) :: k -> k -> Type) Source Github # | |
| (HasBinaryProducts k, Ob s) => FoldFl (Rep (Product s) :: k -> k -> Type) (Corep (Product s) :: k -> k -> Type) Source Github # | |
| (FoldFl f g, FoldFl f' g') => FoldFl (f :.: f' :: k -> k -> Type) (g' :.: g :: j -> j -> Type) Source Github # | |
type Fold (s :: k) (t :: j) (a :: k) (b :: j) = Optic (Prostrong (FoldFl :: (k +-> k) -> (j +-> j) -> Constraint)) s t a b 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, Monoid m, (Ob a, Ob b) => c (ExOptic (FoldFl :: (k +-> k) -> (j +-> j) -> Constraint) a b)) => Optic c s t a b -> (a ~> m) -> s ~> m Source Github #
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)), (Ob a, Ob b) => c (ExOptic (FoldFl :: (OPPOSITE k +-> OPPOSITE k) -> (OPPOSITE k +-> OPPOSITE k) -> Constraint) ('OP b) ('OP a))) => Optic (OpConstraint c) s t a b -> (cm ~> b) -> cm ~> t Source Github #