proarrow
Safe HaskellNone
LanguageGHC2024

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

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

Instances details
(Bicartesian k, Traversable t, Representable t) => FoldRes (t :: k +-> k) (RepCostar t :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Fold

Methods

foldMapP :: forall (m :: k) (s :: k) (a :: k). Monoid m => t s a -> (a ~> m) -> s ~> m Source Github #

(CategoryOf k, CategoryOf j) => FoldRes (Id :: k -> k -> Type) (Id :: j -> j -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Fold

Methods

foldMapP :: forall (m :: k) (s :: k) (a :: k). Monoid m => Id s a -> (a ~> m) -> s ~> m Source Github #

Monoidal k => FoldRes (Two :: k -> k -> Type) (CoTwo :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Kaleidoscope

Methods

foldMapP :: forall (m :: k) (s :: k) (a :: k). Monoid m => Two s a -> (a ~> m) -> s ~> m Source Github #

Monoidal k => FoldRes (UnitW :: k -> k -> Type) (CoUnitW :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Traversal

Methods

foldMapP :: forall (m :: k) (s :: k) (a :: k). Monoid m => UnitW s a -> (a ~> m) -> s ~> m Source Github #

HasInitialObject k => FoldRes (ZeroW :: k -> k -> Type) (CoZeroW :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Traversal

Methods

foldMapP :: forall (m :: k) (s :: k) (a :: k). Monoid m => ZeroW s a -> (a ~> m) -> s ~> m Source Github #

(CategoryOf k, CategoryOf j) => FoldRes (Id :: k -> k -> Type) (TerminalProfunctor :: j -> j -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Fold

Methods

foldMapP :: forall (m :: k) (s :: k) (a :: k). Monoid m => Id s a -> (a ~> m) -> s ~> m Source Github #

(Monoidal k, KnownNat n) => FoldRes (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Kaleidoscope

Methods

foldMapP :: forall (m :: k) (s :: k) (a :: k). Monoid m => Pow n s a -> (a ~> m) -> s ~> m Source Github #

Comonoid m => FoldRes (LensW m :: k -> k -> Type) (CoLensW m :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.MonoidalLens

Methods

foldMapP :: forall (m0 :: k) (s :: k) (a :: k). Monoid m0 => LensW m s a -> (a ~> m0) -> s ~> m0 Source Github #

(CopyDiscard k, Ob a) => FoldRes (TensorW a :: k -> k -> Type) (CoTensorW a :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.MonoidalTraversal

Methods

foldMapP :: forall (m :: k) (s :: k) (a0 :: k). Monoid m => TensorW a s a0 -> (a0 ~> m) -> s ~> m 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 Rep (Constant m) -- the residual shape is simply discarded.

Instance details

Defined in Proarrow.Optic.Fold

Methods

foldMapP :: forall (m :: k) (s :: k) (a :: k). Monoid m => CorepStar t s a -> (a ~> m) -> s ~> m Source Github #

(FoldRes p1 q1, FoldRes p2 q2, Monoidal k) => FoldRes (Beside p1 p2 :: k -> k -> Type) (CoBeside q1 q2 :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Traversal

Methods

foldMapP :: forall (m :: k) (s :: k) (a :: k). Monoid m => Beside p1 p2 s a -> (a ~> m) -> s ~> m 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 # 
Instance details

Defined in Proarrow.Optic.Traversal

Methods

foldMapP :: forall (m :: k) (s :: k) (a :: k). Monoid m => BesideSum p1 p2 s a -> (a ~> m) -> s ~> m Source Github #

(HasCoproducts k, Ob t) => FoldRes (Corep (Coproduct t) :: k -> k -> Type) (Rep (Coproduct t) :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Fold

Methods

foldMapP :: forall (m :: k) (s :: k) (a :: k). Monoid m => Corep (Coproduct t) s a -> (a ~> m) -> s ~> m Source Github #

(CopyDiscard k, HasCoproducts k, Ob t) => FoldRes (Rep (Coproduct t) :: k -> k -> Type) (Corep (Coproduct t) :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Fold

Methods

foldMapP :: forall (m :: k) (s :: k) (a :: k). Monoid m => Rep (Coproduct t) s a -> (a ~> m) -> s ~> m Source Github #

(HasBinaryProducts k, Ob s) => FoldRes (Rep (Product s) :: k -> k -> Type) (Corep (Product s) :: k -> k -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Fold

Methods

foldMapP :: forall (m :: k) (s0 :: k) (a :: k). Monoid m => Rep (Product s) s0 a -> (a ~> m) -> s0 ~> m Source Github #

(FoldRes f g, FoldRes f' g') => FoldRes (f :.: f' :: k -> k -> Type) (g' :.: g :: j -> j -> Type) Source Github # 
Instance details

Defined in Proarrow.Optic.Fold

Methods

foldMapP :: forall (m :: k) (s :: k) (a :: k). Monoid m => (f :.: f') s a -> (a ~> m) -> s ~> m 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 

Fields

  • :: forall {j} {k} (t :: j) (s :: k) (m :: k). Ob t
     
  • => { unForget :: s ~> m
     
  •    } -> Forget m s t
     

Instances

Instances details
(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 Forget carrier.

Instance details

Defined in Proarrow.Optic.Fold

Methods

proact :: forall (f :: k +-> k) (g :: j +-> j). (w f g, Profunctor f, Profunctor g) => ((f :.: (Forget m :: k -> j -> Type)) :.: g) :~> (Forget m :: k -> j -> Type) Source Github #

(CategoryOf j, CategoryOf k, Ob m) => Profunctor (Forget m :: k -> j -> Type) Source Github # 
Instance details

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 #

The genuine unfold: build t from a Comonoid seed cm through the b-foci. It is foldMapOf run in OPPOSITE k, where Monoid becomes Comonoid and consumption becomes construction. (Inhabitable once the flavor's Prostrong transports through OP.)