profunctors-5.1: Profunctors

Data.Profunctor.Composition

Description

Synopsis

Profunctor Composition

data Procompose p q d c where Source

Procompose p q is the Profunctor composition of the Profunctors p and q.

For a good explanation of Profunctor composition in Haskell see Dan Piponi's article:

Constructors

 Procompose :: p x c -> q d x -> Procompose p q d c

Instances

 Category * p => ProfunctorMonad (Procompose p) ProfunctorFunctor (Procompose p) ProfunctorAdjunction (Procompose p) (Rift p) (Profunctor p, Profunctor q) => Profunctor (Procompose p q) (Corepresentable p, Corepresentable q) => Costrong (Procompose p q) (Choice p, Choice q) => Choice (Procompose p q) (Strong p, Strong q) => Strong (Procompose p q) (Closed p, Closed q) => Closed (Procompose p q) (Corepresentable p, Corepresentable q) => Corepresentable (Procompose p q) (Representable p, Representable q) => Representable (Procompose p q) The composition of two Representable Profunctors is Representable by the composition of their representations. (Cosieve p f, Cosieve q g) => Cosieve (Procompose p q) (Compose f g) (Sieve p f, Sieve q g) => Sieve (Procompose p q) (Compose g f) Profunctor p => Functor (Procompose p q a) type Corep (Procompose p q) = Compose (Corep p) (Corep q) type Rep (Procompose p q) = Compose (Rep q) (Rep p)

procomposed :: Category p => Procompose p p a b -> p a b Source

Unitors and Associator

idl :: Profunctor q => Iso (Procompose (->) q d c) (Procompose (->) r d' c') (q d c) (r d' c') Source

(->) functions as a lax identity for Profunctor composition.

This provides an Iso for the lens package that witnesses the isomorphism between Procompose (->) q d c and q d c, which is the left identity law.

idl :: Profunctor q => Iso' (Procompose (->) q d c) (q d c)

idr :: Profunctor q => Iso (Procompose q (->) d c) (Procompose r (->) d' c') (q d c) (r d' c') Source

(->) functions as a lax identity for Profunctor composition.

This provides an Iso for the lens package that witnesses the isomorphism between Procompose q (->) d c and q d c, which is the right identity law.

idr :: Profunctor q => Iso' (Procompose q (->) d c) (q d c)

assoc :: Iso (Procompose p (Procompose q r) a b) (Procompose x (Procompose y z) a b) (Procompose (Procompose p q) r a b) (Procompose (Procompose x y) z a b) Source

The associator for Profunctor composition.

This provides an Iso for the lens package that witnesses the isomorphism between Procompose p (Procompose q r) a b and Procompose (Procompose p q) r a b, which arises because Prof is only a bicategory, rather than a strict 2-category.

Generalized Composition

stars :: Functor g => Iso (Procompose (Star f) (Star g) d c) (Procompose (Star f') (Star g') d' c') (Star (Compose g f) d c) (Star (Compose g' f') d' c') Source

Profunctor composition generalizes Functor composition in two ways.

This is the first, which shows that exists b. (a -> f b, b -> g c) is isomorphic to a -> f (g c).

stars :: Functor f => Iso' (Procompose (Star f) (Star g) d c) (Star (Compose f g) d c)

kleislis :: Monad g => Iso (Procompose (Kleisli f) (Kleisli g) d c) (Procompose (Kleisli f') (Kleisli g') d' c') (Kleisli (Compose g f) d c) (Kleisli (Compose g' f') d' c') Source

This is a variant on stars that uses Kleisli instead of Star.

kleislis :: Monad f => Iso' (Procompose (Kleisli f) (Kleisli g) d c) (Kleisli (Compose f g) d c)

costars :: Functor f => Iso (Procompose (Costar f) (Costar g) d c) (Procompose (Costar f') (Costar g') d' c') (Costar (Compose f g) d c) (Costar (Compose f' g') d' c') Source

Profunctor composition generalizes Functor composition in two ways.

This is the second, which shows that exists b. (f a -> b, g b -> c) is isomorphic to g (f a) -> c.

costars :: Functor f => Iso' (Procompose (Costar f) (Costar g) d c) (Costar (Compose g f) d c)

cokleislis :: Functor f => Iso (Procompose (Cokleisli f) (Cokleisli g) d c) (Procompose (Cokleisli f') (Cokleisli g') d' c') (Cokleisli (Compose f g) d c) (Cokleisli (Compose f' g') d' c') Source

This is a variant on costars that uses Cokleisli instead of Costar.

cokleislis :: Functor f => Iso' (Procompose (Cokleisli f) (Cokleisli g) d c) (Cokleisli (Compose g f) d c)

Right Kan Lift

newtype Rift p q a b Source

This represents the right Kan lift of a Profunctor q along a Profunctor p in a limited version of the 2-category of Profunctors where the only object is the category Hask, 1-morphisms are profunctors composed and compose with Profunctor composition, and 2-morphisms are just natural transformations.

Constructors

 Rift FieldsrunRift :: forall x. p b x -> q a x

Instances

 (~) (* -> * -> *) p q => Category * (Rift p q) Rift p p forms a Monad in the Profunctor 2-category, which is isomorphic to a Haskell Category instance. Category * p => ProfunctorComonad (Rift p) ProfunctorFunctor (Rift p) ProfunctorAdjunction (Procompose p) (Rift p) (Profunctor p, Profunctor q) => Profunctor (Rift p q) Profunctor p => Functor (Rift p q a)

decomposeRift :: Procompose p (Rift p q) :-> q Source

The 2-morphism that defines a left Kan lift.

Note: When p is right adjoint to Rift p (->) then decomposeRift is the counit of the adjunction.