Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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:
lmap
id
=id
lmap
(i>>>
j) =lmap
i.
lmap
j
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
(arr
f) (p<*>
q) =lmap
(arr
f) p<*>
lmap
(arr
f) q
lmap
(arr
f) (pure
a) =pure
a
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
(first
i) (lmap
(arr
fst
) p<*>
lmap
(arr
snd
) q) =lmap
(first
i>>>
arr
fst
) p<*>
lmap
(arr
snd
) q
(=.) :: (Cofunctor p, Arrow (First p)) => (y -> x) -> p x a -> p y a infixl 5 Source #
Mapping with a regular function.