| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Profunctor.Monad.Cofunctor
Synopsis
- type Profunctor p = (Cofunctor p, ForallF Functor p)
- class Category (First p) => Cofunctor p where
- (=.) :: (Cofunctor p, Arrow (First p)) => (y -> x) -> p x a -> p y a
- (=:) :: (Cofunctor p, First p ~ Kleisli m) => (y -> m x) -> p x a -> p y a
- cofilter :: (Cofunctor p, First p ~ Kleisli m, Alternative m) => (x -> Bool) -> p x a -> p x a
Documentation
type Profunctor p = (Cofunctor p, ForallF Functor p) Source #
A Profunctor is a bifunctor p :: * -> * -> * from the product of an
arbitrary category, denoted , and First p(->).
This is a generalization of the profunctors package's Profunctor,
where .First p ~ (->)
A profunctor is two functors on different domains at once, one
contravariant, one covariant, and that is made clear by this definition
specifying Cofunctor and Functor separately.
class Category (First p) => Cofunctor p where Source #
Types p :: * -> * -> * which are contravariant functors
over their first parameter.
Functor laws:
lmapid=idlmap(i>>>j) =lmapi.lmapj
If the domain is an First pArrow, and if for every a, the type
p a is an instance of Applicative, then a pure arrow arr f should
correspond to an "applicative natural transformation":
lmap(arrf) (p<*>q) =lmap(arrf) p<*>lmap(arrf) q
lmap(arrf) (purea) =purea
The following may not be true in general, but seems to hold in practice,
when the instance orders effects from left to right,
in particular that should be the case if there is also a Applicative (p a):Monad (p a)
lmap(firsti) (lmap(arrfst) p<*>lmap(arrsnd) q) =lmap(firsti>>>arrfst) p<*>lmap(arrsnd) q
(=.) :: (Cofunctor p, Arrow (First p)) => (y -> x) -> p x a -> p y a infixl 5 Source #
Mapping with a regular function.