| 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 | Safe |
| Language | Haskell2010 |
Data.Profunctor.Composition
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 Source #
is the Procompose p qProfunctor composition of the
Profunctors 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
Procompose has a polymorphic kind since 5.6.
Constructors
| Procompose :: p x c -> q d x -> Procompose p q d c |
Instances
| ProfunctorFunctor (Procompose p :: (Type -> Type -> Type) -> Type -> k -> Type) Source # | |
Defined in Data.Profunctor.Composition Methods promap :: forall (p0 :: Type -> Type -> Type) (q :: Type -> Type -> Type). Profunctor p0 => (p0 :-> q) -> Procompose p p0 :-> Procompose p q Source # | |
| Category p => ProfunctorMonad (Procompose p :: (Type -> Type -> Type) -> Type -> Type -> Type) Source # | |
Defined in Data.Profunctor.Composition Methods proreturn :: forall (p0 :: Type -> Type -> Type). Profunctor p0 => p0 :-> Procompose p p0 Source # projoin :: forall (p0 :: Type -> Type -> Type). Profunctor p0 => Procompose p (Procompose p p0) :-> Procompose p p0 Source # | |
| ProfunctorAdjunction (Procompose p :: (Type -> Type -> Type) -> Type -> Type -> Type) (Rift p :: (Type -> Type -> Type) -> Type -> Type -> Type) Source # | |
Defined in Data.Profunctor.Composition Methods unit :: forall (p0 :: Type -> Type -> Type). Profunctor p0 => p0 :-> Rift p (Procompose p p0) Source # counit :: forall (p0 :: Type -> Type -> Type). Profunctor p0 => Procompose p (Rift p p0) :-> p0 Source # | |
| (Profunctor p, Profunctor q) => Profunctor (Procompose p q) Source # | |
Defined in Data.Profunctor.Composition Methods dimap :: (a -> b) -> (c -> d) -> Procompose p q b c -> Procompose p q a d Source # lmap :: (a -> b) -> Procompose p q b c -> Procompose p q a c Source # rmap :: (b -> c) -> Procompose p q a b -> Procompose p q a c Source # (#.) :: forall a b c q0. Coercible c b => q0 b c -> Procompose p q a b -> Procompose p q a c Source # (.#) :: forall a b c q0. Coercible b a => Procompose p q b c -> q0 a b -> Procompose p q a c Source # | |
| (Corepresentable p, Corepresentable q) => Costrong (Procompose p q) Source # | |
Defined in Data.Profunctor.Composition Methods unfirst :: Procompose p q (a, d) (b, d) -> Procompose p q a b Source # unsecond :: Procompose p q (d, a) (d, b) -> Procompose p q a b Source # | |
| (Strong p, Strong q) => Strong (Procompose p q) Source # | |
Defined in Data.Profunctor.Composition Methods first' :: Procompose p q a b -> Procompose p q (a, c) (b, c) Source # second' :: Procompose p q a b -> Procompose p q (c, a) (c, b) Source # | |
| (Closed p, Closed q) => Closed (Procompose p q) Source # | |
Defined in Data.Profunctor.Composition Methods closed :: Procompose p q a b -> Procompose p q (x -> a) (x -> b) Source # | |
| (Choice p, Choice q) => Choice (Procompose p q) Source # | |
Defined in Data.Profunctor.Composition Methods left' :: Procompose p q a b -> Procompose p q (Either a c) (Either b c) Source # right' :: Procompose p q a b -> Procompose p q (Either c a) (Either c b) Source # | |
| (Traversing p, Traversing q) => Traversing (Procompose p q) Source # | |
Defined in Data.Profunctor.Composition Methods traverse' :: Traversable f => Procompose p q a b -> Procompose p q (f a) (f b) Source # wander :: (forall (f :: Type -> Type). Applicative f => (a -> f b) -> s -> f t) -> Procompose p q a b -> Procompose p q s t Source # | |
| (Mapping p, Mapping q) => Mapping (Procompose p q) Source # | |
Defined in Data.Profunctor.Composition Methods map' :: Functor f => Procompose p q a b -> Procompose p q (f a) (f b) Source # roam :: ((a -> b) -> s -> t) -> Procompose p q a b -> Procompose p q s t Source # | |
| (Corepresentable p, Corepresentable q) => Corepresentable (Procompose p q) Source # | |
Defined in Data.Profunctor.Composition Associated Types type Corep (Procompose p q) :: Type -> Type Source # Methods cotabulate :: (Corep (Procompose p q) d -> c) -> Procompose p q d c Source # | |
| (Representable p, Representable q) => Representable (Procompose p q) Source # | The composition of two |
Defined in Data.Profunctor.Composition Associated Types type Rep (Procompose p q) :: Type -> Type Source # Methods tabulate :: (d -> Rep (Procompose p q) c) -> Procompose p q d c Source # | |
| (Cosieve p f, Cosieve q g) => Cosieve (Procompose p q) (Compose f g) Source # | |
Defined in Data.Profunctor.Composition Methods cosieve :: Procompose p q a b -> Compose f g a -> b Source # | |
| (Sieve p f, Sieve q g) => Sieve (Procompose p q) (Compose g f) Source # | |
Defined in Data.Profunctor.Composition Methods sieve :: Procompose p q a b -> a -> Compose g f b Source # | |
| Profunctor p => Functor (Procompose p q a) Source # | |
Defined in Data.Profunctor.Composition Methods fmap :: (a0 -> b) -> Procompose p q a a0 -> Procompose p q a b (<$) :: a0 -> Procompose p q a b -> Procompose p q a a0 | |
| type Corep (Procompose p q) Source # | |
Defined in Data.Profunctor.Composition | |
| type Rep (Procompose p q) Source # | |
Defined in Data.Profunctor.Composition | |
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 and Procompose (->) q d cq d c, which
is the left identity law.
idl::Profunctorq => 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 and Procompose q (->) d cq d c, which
is the right identity law.
idr::Profunctorq => Iso' (Procomposeq (->) 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 and
Procompose p (Procompose q r) a b, which arises because
Procompose (Procompose p q) r a bProf is only a bicategory, rather than a strict 2-category.
Categories as monoid objects
eta :: (Profunctor p, Category p) => (->) :-> p Source #
a Category that is also a Profunctor is a Monoid in Prof
mu :: Category p => Procompose p p :-> p Source #
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::Functorf => Iso' (Procompose(Starf) (Starg) d c) (Star(Composef 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::Monadf => Iso' (Procompose(Kleislif) (Kleislig) d c) (Kleisli(Composef 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::Functorf => Iso' (Procompose(Costarf) (Costarg) d c) (Costar(Composeg 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::Functorf => Iso' (Procompose(Cokleislif) (Cokleislig) d c) (Cokleisli(Composeg f) d c)
Right Kan Lift
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.
Rift has a polymorphic kind since 5.6.
Instances
| p ~ q => Category (Rift p q :: k1 -> k1 -> Type) Source # |
|
| ProfunctorFunctor (Rift p :: (Type -> Type -> Type) -> Type -> k -> Type) Source # | |
Defined in Data.Profunctor.Composition | |
| Category p => ProfunctorComonad (Rift p :: (Type -> Type -> Type) -> Type -> Type -> Type) Source # | |
Defined in Data.Profunctor.Composition Methods proextract :: forall (p0 :: Type -> Type -> Type). Profunctor p0 => Rift p p0 :-> p0 Source # produplicate :: forall (p0 :: Type -> Type -> Type). Profunctor p0 => Rift p p0 :-> Rift p (Rift p p0) Source # | |
| ProfunctorAdjunction (Procompose p :: (Type -> Type -> Type) -> Type -> Type -> Type) (Rift p :: (Type -> Type -> Type) -> Type -> Type -> Type) Source # | |
Defined in Data.Profunctor.Composition Methods unit :: forall (p0 :: Type -> Type -> Type). Profunctor p0 => p0 :-> Rift p (Procompose p p0) Source # counit :: forall (p0 :: Type -> Type -> Type). Profunctor p0 => Procompose p (Rift p p0) :-> p0 Source # | |
| (Profunctor p, Profunctor q) => Profunctor (Rift p q) Source # | |
Defined in Data.Profunctor.Composition Methods dimap :: (a -> b) -> (c -> d) -> Rift p q b c -> Rift p q a d Source # lmap :: (a -> b) -> Rift p q b c -> Rift p q a c Source # rmap :: (b -> c) -> Rift p q a b -> Rift p q a c Source # (#.) :: forall a b c q0. Coercible c b => q0 b c -> Rift p q a b -> Rift p q a c Source # (.#) :: forall a b c q0. Coercible b a => Rift p q b c -> q0 a b -> Rift p q a c Source # | |
| Profunctor p => Functor (Rift p q a) Source # | |
decomposeRift :: Procompose p (Rift p q) :-> q Source #
The 2-morphism that defines a left Kan lift.
Note: When p is right adjoint to then Rift p (->)decomposeRift is the counit of the adjunction.