Data.Profunctor.Composition

profunctors-5.2: Profunctors

Copyright | (C) 2014-2015 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | experimental
Portability | GADTs, TFs, MPTCs, RankN
Safe Haskell | None
Language | Haskell2010

Data.Profunctor.Composition

Contents

- Profunctor Composition
- Unitors and Associator
- Categories as monoid objects
- Generalized Composition
- Right Kan Lift

Description

Synopsis

- data Procompose p q d c where
  - Procompose :: p x c -> q d x -> Procompose p q d c
- procomposed :: Category p => Procompose p p a b -> p a b
- idl :: Profunctor q => Iso (Procompose (->) q d c) (Procompose (->) r d' c') (q d c) (r d' c')
- idr :: Profunctor q => Iso (Procompose q (->) d c) (Procompose r (->) d' c') (q d c) (r 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)
- eta :: (Profunctor p, Category p) => (->) :-> p
- mu :: Category p => Procompose p p :-> p
- 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')
- 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')
- 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')
- 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')
- newtype Rift p q a b = Rift {
  - runRift :: forall x. p b x -> q a x
  }
- decomposeRift :: Procompose p (Rift p q) :-> q

# Profunctor Composition

data Procompose p q d c where #

``Procompose` p q` is the `Profunctor` composition of the `Profunctor`s `p` and `q`.

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

http://blog.sigfpe.com/2011/07/profunctors-in-haskell.html

Constructors

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

Instances

Category * p => ProfunctorMonad (Procompose p) # |
Methods proreturn :: Profunctor p => p :-> Procompose p p # projoin :: Profunctor p => Procompose p (Procompose p p) :-> Procompose p p #
ProfunctorFunctor (Procompose p) # |
Methods promap :: Profunctor p => (p :-> q) -> Procompose p p :-> Procompose p q #
ProfunctorAdjunction (Procompose p) (Rift p) # |
Methods unit :: Profunctor p => p :-> Rift p (Procompose p p) # counit :: Profunctor p => Procompose p (Rift p p) :-> p #
(Profunctor p, Profunctor q) => Profunctor (Procompose p q) # |
Methods dimap :: (a -> b) -> (c -> d) -> Procompose p q b c -> Procompose p q a d # lmap :: (a -> b) -> Procompose p q b c -> Procompose p q a c # rmap :: (b -> c) -> Procompose p q a b -> Procompose p q a c # (#.) :: Coercible * c b => (b -> c) -> Procompose p q a b -> Procompose p q a c # (.#) :: Coercible * b a => Procompose p q b c -> (a -> b) -> Procompose p q a c #
(Corepresentable p, Corepresentable q) => Costrong (Procompose p q) # |
Methods unfirst :: Procompose p q (a, d) (b, d) -> Procompose p q a b # unsecond :: Procompose p q (d, a) (d, b) -> Procompose p q a b #
(Strong p, Strong q) => Strong (Procompose p q) # |
Methods first' :: Procompose p q a b -> Procompose p q (a, c) (b, c) # second' :: Procompose p q a b -> Procompose p q (c, a) (c, b) #
(Closed p, Closed q) => Closed (Procompose p q) # |
Methods closed :: Procompose p q a b -> Procompose p q (x -> a) (x -> b) #
(Choice p, Choice q) => Choice (Procompose p q) # |
Methods left' :: Procompose p q a b -> Procompose p q (Either a c) (Either b c) # right' :: Procompose p q a b -> Procompose p q (Either c a) (Either c b) #
(Corepresentable p, Corepresentable q) => Corepresentable (Procompose p q) # |
Associated Types type Corep (Procompose p q :: * -> * -> *) :: * -> * # Methods cotabulate :: (Corep (Procompose p q) d -> c) -> Procompose p q d c #
(Representable p, Representable q) => Representable (Procompose p q) # | The composition of two `Representable` `Profunctor`s is `Representable` by the composition of their representations.
Associated Types type Rep (Procompose p q :: * -> * -> *) :: * -> * # Methods tabulate :: (d -> Rep (Procompose p q) c) -> Procompose p q d c #
(Cosieve p f, Cosieve q g) => Cosieve (Procompose p q) (Compose * * f g) # |
Methods cosieve :: Procompose p q a b -> Compose * * f g a -> b #
(Sieve p f, Sieve q g) => Sieve (Procompose p q) (Compose * * g f) # |
Methods sieve :: Procompose p q a b -> a -> Compose * * g f b #
Profunctor p => Functor (Procompose p q a) # |
Methods fmap :: (a -> b) -> Procompose p q a a -> Procompose p q a b # (<$) :: a -> Procompose p q a b -> Procompose p q a a #
type Corep (Procompose p q) # |
type Corep (Procompose p q) = Compose * * (Corep p) (Corep q)
type Rep (Procompose p q) # |
type Rep (Procompose p q) = Compose * * (Rep q) (Rep p)

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

# Unitors and Associator

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

`(->)` 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') #

`(->)` 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) #

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.

# Categories as monoid objects

eta :: (Profunctor p, Category p) => (->) :-> p #

a `Category` that is also a `Profunctor` is a `Monoid` in `Prof`

mu :: Category p => Procompose p p :-> p #

# 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') #

`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') #

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') #

`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') #

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 #

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 |
Fields runRift :: forall x. p b x -> q a x

Instances

Category * p => ProfunctorComonad (Rift p) # |
Methods proextract :: Profunctor p => Rift p p :-> p # produplicate :: Profunctor p => Rift p p :-> Rift p (Rift p p) #
ProfunctorFunctor (Rift p) # |
Methods promap :: Profunctor p => (p :-> q) -> Rift p p :-> Rift p q #
ProfunctorAdjunction (Procompose p) (Rift p) # |
Methods unit :: Profunctor p => p :-> Rift p (Procompose p p) # counit :: Profunctor p => Procompose p (Rift p p) :-> p #
(~) (* -> * -> *) 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.
Methods id :: cat a a # (.) :: cat b c -> cat a b -> cat a c #
(Profunctor p, Profunctor q) => Profunctor (Rift p q) # |
Methods dimap :: (a -> b) -> (c -> d) -> Rift p q b c -> Rift p q a d # lmap :: (a -> b) -> Rift p q b c -> Rift p q a c # rmap :: (b -> c) -> Rift p q a b -> Rift p q a c # (#.) :: Coercible * c b => (b -> c) -> Rift p q a b -> Rift p q a c # (.#) :: Coercible * b a => Rift p q b c -> (a -> b) -> Rift p q a c #
Profunctor p => Functor (Rift p q a) # |
Methods fmap :: (a -> b) -> Rift p q a a -> Rift p q a b # (<$) :: a -> Rift p q a b -> Rift p q a a #

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

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.