| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Proarrow.Optic.Kaleidoscope
Description
The cotraversal and the kaleidoscope: two flavors with the same witnesses (the
representable StrongDistributiveProfunctors, i.e. applicative functors rendered as profunctors,
with their RepCostars) that differ in what they can be eliminated through.
Both mirror MonTravFl. All three rest on the square
t :.: p ~> p :.: t between a functor t and a StrongDistributiveProfunctor p (in Type,
sequenceA :: t (f a) -> f (t a)). A monoidal traversal takes t as the witness and quantifies
over p; the optics here take p as the witness and quantify over t.
- A
Cotraversalpasses through everyCotraversablecarrier: the square for arbitraryp. This holds for shapes with a list of contents (Cotraversable(for a traversable representableRepCostart)t,Id, products, sums, and inTypefor a PreludeCostar(Preludet)Traversable t, theAggregatingmodule of the literature). - A
Kaleidoscopepasses through everyKaleidoscopiccarrier: the square for representableponly. This is the kaleidoscope of Clarke et al. (Profunctor optics: a categorical update),∫^{F applicative} C(S, F A) × C(F B, T). It admits every applicative, including ones with no list of contents such as the reader(->) r, which are notCotraversable.
Every Cotraversable carrier is Kaleidoscopic (cotravAct), so :
the kaleidoscope is the stronger flavor. Both sit below KaleidoFl <: CotravFlSetterFl only,
since one can over through an applicative but not fold out of one.
PowerGrateFl (the reader applicative) and the tensor-action pair for
a monoid residual (the writer applicative) are subflavors of KaleidoFl, which is how an
algebraic lens for the list monad composes with a kaleidoscope
(ClassifyFl).
Synopsis
- class SetterFl p q => CotravFl (p :: k +-> k) (q :: k +-> k) where
- cotravP :: forall r (s :: k) (a :: k) (b :: k) (t :: k). Cotraversable r => p s a -> q b t -> r a b -> r s t
- type Cotraversal (s :: k) (t :: k) (a :: k) (b :: k) = Optic (Prostrong (CotravFl :: (k +-> k) -> (k +-> k) -> Constraint)) s t a b
- type Cotraversal' (s :: k) (a :: k) = Cotraversal s s a a
- cotraversal :: forall {k} (p :: k +-> k) (s :: k) (t :: k) (a :: k) (b :: k). (Representable p, StrongDistributiveProfunctor p, Ob a, Ob b) => (s ~> (p % a)) -> ((p % b) ~> t) -> Cotraversal s t a b
- cotraverseOf :: forall {k} (c :: (k -> k -> Type) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k) r. (CategoryOf k, Cotraversable r, (Ob a, Ob b) => c (ExOptic (CotravFl :: (k +-> k) -> (k +-> k) -> Constraint) a b)) => Optic c s t a b -> r a b -> r s t
- class CotravFl p q => KaleidoFl (p :: k +-> k) (q :: k +-> k) where
- kaleidoP :: forall r (s :: k) (a :: k) (b :: k) (t :: k). Kaleidoscopic r => p s a -> q b t -> r a b -> r s t
- type Kaleidoscope (s :: k) (t :: k) (a :: k) (b :: k) = Optic (Prostrong (KaleidoFl :: (k +-> k) -> (k +-> k) -> Constraint)) s t a b
- type Kaleidoscope' (s :: k) (a :: k) = Kaleidoscope s s a a
- kaleidoscope :: forall {k} (p :: k +-> k) (s :: k) (t :: k) (a :: k) (b :: k). (Representable p, StrongDistributiveProfunctor p, Ob a, Ob b) => (s ~> (p % a)) -> ((p % b) ~> t) -> Kaleidoscope s t a b
- kaleidoscopeOf :: forall {k} (c :: (k -> k -> Type) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k) r. (CategoryOf k, Kaleidoscopic r, (Ob a, Ob b) => c (ExOptic (KaleidoFl :: (k +-> k) -> (k +-> k) -> Constraint) a b)) => Optic c s t a b -> r a b -> r s t
- class Profunctor r => Kaleidoscopic (r :: k +-> k) where
- kaleidoAct :: forall (p :: k +-> k) (a :: k) (b :: k). (Representable p, StrongDistributiveProfunctor p) => r a b -> r (p % a) (p % b)
- cotravAct :: forall {k} (p :: k +-> k) r (a :: k) (b :: k). (Cotraversable r, Representable p, StrongDistributiveProfunctor p) => r a b -> r (p % a) (p % b)
- newtype CotravAs (r :: k -> k1 -> Type) (a :: k) (b :: k1) = CotravAs {
- unCotravAs :: r a b
- newtype WrapRep (p :: j +-> Type) (x :: j) = WrapRep {}
The cotraversal
class SetterFl p q => CotravFl (p :: k +-> k) (q :: k +-> k) where Source Github #
The cotraversal flavor: pass any Cotraversable carrier through the witness pair. The
mirror of MonTravFl, with witness and carrier swapped.
Minimal complete definition
Nothing
Methods
cotravP :: forall r (s :: k) (a :: k) (b :: k) (t :: k). Cotraversable r => p s a -> q b t -> r a b -> r s t Source Github #
Instances
| (Representable p, StrongDistributiveProfunctor p) => CotravFl (p :: k +-> k) (RepCostar p :: k -> k -> Type) Source Github # | The generating witnesses: any representable |
Defined in Proarrow.Optic.Kaleidoscope | |
| CategoryOf k => CotravFl (Id :: k -> k -> Type) (Id :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.Kaleidoscope | |
| (CopyDiscard k, HasCoproducts k, SNatI n) => CotravFl (Pow n :: k -> k -> Type) (CoPow n :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.PowerGrate | |
| (SymMonoidal k, HasCoproducts k, Monoid m) => CotravFl (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 pair for a monoid residual: |
| (Closed k, SymMonoidal k, HasCoproducts k, CocommutativeComonoid m) => CotravFl (Rep (Exp m) :: k -> k -> Type) (Corep (Exp m) :: k -> k -> Type) Source Github # | The exponential pair for a comonoid exponent: |
Defined in Proarrow.Optic.Kaleidoscope | |
| (CotravFl f g, CotravFl f' g') => CotravFl (f :.: f' :: i -> i -> Type) (g' :.: g :: i -> i -> Type) Source Github # | |
Defined in Proarrow.Optic.Kaleidoscope | |
type Cotraversal (s :: k) (t :: k) (a :: k) (b :: k) = Optic (Prostrong (CotravFl :: (k +-> k) -> (k +-> k) -> Constraint)) s t a b Source Github #
type Cotraversal' (s :: k) (a :: k) = Cotraversal s s a a Source Github #
cotraversal :: forall {k} (p :: k +-> k) (s :: k) (t :: k) (a :: k) (b :: k). (Representable p, StrongDistributiveProfunctor p, Ob a, Ob b) => (s ~> (p % a)) -> ((p % b) ~> t) -> Cotraversal s t a b Source Github #
Build a cotraversal from its legs through an applicative functor, given as a representable
StrongDistributiveProfunctor p.
cotraverseOf :: forall {k} (c :: (k -> k -> Type) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k) r. (CategoryOf k, Cotraversable r, (Ob a, Ob b) => c (ExOptic (CotravFl :: (k +-> k) -> (k +-> k) -> Constraint) a b)) => Optic c s t a b -> r a b -> r s t Source Github #
Pass a Cotraversable carrier through a cotraversal (or any stronger optic, in any encoding,
(%)-composites included).
The kaleidoscope
class CotravFl p q => KaleidoFl (p :: k +-> k) (q :: k +-> k) where Source Github #
The kaleidoscope flavor: act on any Kaleidoscopic carrier through the witness pair.
Methods
kaleidoP :: forall r (s :: k) (a :: k) (b :: k) (t :: k). Kaleidoscopic r => p s a -> q b t -> r a b -> r s t Source Github #
Instances
type Kaleidoscope (s :: k) (t :: k) (a :: k) (b :: k) = Optic (Prostrong (KaleidoFl :: (k +-> k) -> (k +-> k) -> Constraint)) s t a b Source Github #
type Kaleidoscope' (s :: k) (a :: k) = Kaleidoscope s s a a Source Github #
kaleidoscope :: forall {k} (p :: k +-> k) (s :: k) (t :: k) (a :: k) (b :: k). (Representable p, StrongDistributiveProfunctor p, Ob a, Ob b) => (s ~> (p % a)) -> ((p % b) ~> t) -> Kaleidoscope s t a b Source Github #
Build a kaleidoscope from the same legs.
kaleidoscopeOf :: forall {k} (c :: (k -> k -> Type) -> Constraint) (s :: k) (t :: k) (a :: k) (b :: k) r. (CategoryOf k, Kaleidoscopic r, (Ob a, Ob b) => c (ExOptic (KaleidoFl :: (k +-> k) -> (k +-> k) -> Constraint) a b)) => Optic c s t a b -> r a b -> r s t Source Github #
Act on a Kaleidoscopic carrier through a kaleidoscope (or any stronger optic, in any
encoding, (%)-composites included). At this is the literature's
aggregation operator Costar []>-: from [a] -> b to [s] -> t.
Carriers
class Profunctor r => Kaleidoscopic (r :: k +-> k) where Source Github #
The carriers of the kaleidoscope: profunctors that every representable
StrongDistributiveProfunctor p (i.e. every applicative functor p % -) acts on by
application. Where a traversal's carriers are the applicatives themselves, a kaleidoscope's
carriers are the things applicatives can be sequenced through. These are every Cotraversable
profunctor (cotravAct), and in Type also for any Costar tTraversable t (
directly, and Costar [] for a Costar (Prelude t)t that has no Functor instance
of its own).
Methods
kaleidoAct :: forall (p :: k +-> k) (a :: k) (b :: k). (Representable p, StrongDistributiveProfunctor p) => r a b -> r (p % a) (p % b) Source Github #
Instances
| Traversable t => Kaleidoscopic (Costar (Prelude t) :: Type -> Type -> Type) Source Github # |
|
Defined in Proarrow.Optic.Kaleidoscope Methods kaleidoAct :: forall (p :: Type +-> Type) a b. (Representable p, StrongDistributiveProfunctor p) => Costar (Prelude t) a b -> Costar (Prelude t) (p % a) (p % b) Source Github # | |
| Kaleidoscopic (Costar []) Source Github # | The same for |
Defined in Proarrow.Optic.Kaleidoscope Methods kaleidoAct :: forall (p :: Type +-> Type) a b. (Representable p, StrongDistributiveProfunctor p) => Costar [] a b -> Costar [] (p % a) (p % b) Source Github # | |
| Cotraversable r => Kaleidoscopic (CotravAs r :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.Kaleidoscope Methods kaleidoAct :: forall (p :: k +-> k) (a :: k) (b :: k). (Representable p, StrongDistributiveProfunctor p) => CotravAs r a b -> CotravAs r (p % a) (p % b) Source Github # | |
| (Traversable t, Representable t) => Kaleidoscopic (RepCostar t :: k -> k -> Type) Source Github # | The general carrier: the |
Defined in Proarrow.Optic.Kaleidoscope Methods kaleidoAct :: forall (p :: k +-> k) (a :: k) (b :: k). (Representable p, StrongDistributiveProfunctor p) => RepCostar t a b -> RepCostar t (p % a) (p % b) Source Github # | |
cotravAct :: forall {k} (p :: k +-> k) r (a :: k) (b :: k). (Cotraversable r, Representable p, StrongDistributiveProfunctor p) => r a b -> r (p % a) (p % b) Source Github #
kaleidoAct for any Cotraversable carrier: let the witness through.
newtype CotravAs (r :: k -> k1 -> Type) (a :: k) (b :: k1) Source Github #
A Cotraversable carrier, tagged as the Kaleidoscopic carrier it also is. With it every
kaleidoscope witness is a cotraversal witness (the default cotravP).
Constructors
| CotravAs | |
Fields
| |
Instances
| Profunctor r => Profunctor (CotravAs r :: k -> j -> Type) Source Github # | |
Defined in Proarrow.Optic.Kaleidoscope Methods dimap :: forall (c :: k) (a :: k) (b :: j) (d :: j). (c ~> a) -> (b ~> d) -> CotravAs r a b -> CotravAs r c d Source Github # lmap :: forall (c :: k) (a :: k) (b :: j). (c ~> a) -> CotravAs r a b -> CotravAs r c b Source Github # rmap :: forall (b :: j) (d :: j) (a :: k). (b ~> d) -> CotravAs r a b -> CotravAs r a d Source Github # (\\) :: forall (a :: k) (b :: j) r0. ((Ob a, Ob b) => r0) -> CotravAs r a b -> r0 Source Github # | |
| Cotraversable r => Kaleidoscopic (CotravAs r :: k -> k -> Type) Source Github # | |
Defined in Proarrow.Optic.Kaleidoscope Methods kaleidoAct :: forall (p :: k +-> k) (a :: k) (b :: k). (Representable p, StrongDistributiveProfunctor p) => CotravAs r a b -> CotravAs r (p % a) (p % b) Source Github # | |
newtype WrapRep (p :: j +-> Type) (x :: j) Source Github #
The applicative functor a representable StrongDistributiveProfunctor on Type represents:
pure is one and liftA2 is **.
Instances
| (Representable p, StrongDistributiveProfunctor p) => Applicative (WrapRep p) Source Github # | |
Defined in Proarrow.Optic.Kaleidoscope | |
| Representable p => Functor (WrapRep p) Source Github # | |
Orphan instances
| (Closed k, SymMonoidal k, Ob m) => Strong (Tensor :: k -> (k, k) -> Type) (Rep (Exp m) :: k -> k -> Type) Source Github # | |
| (Closed k, SymMonoidal k, CocommutativeComonoid m) => MonoidalProfunctor (Rep (Exp m) :: k -> k -> Type) Source Github # | The exponential by a comonoid, |
| (Closed k, SymMonoidal k, HasCoproducts k, CocommutativeComonoid m) => Traversing (Rep (Exp m) :: k -> k -> Type) Source Github # | |
| (Closed k, HasCoproducts k, Comonoid m) => Strong (CoprodAction :: k -> (COPROD k, k) -> Type) (Rep (Exp m) :: k -> k -> Type) Source Github # | |
| (Closed k, HasCoproducts k, Ob m) => MonoidalProfunctor (Coprod (Rep (Exp m)) :: COPROD k -> COPROD k -> Type) Source Github # | |