Module
Data.Profunctor
- Package
- purescript-profunctor
- Repository
- purescript/purescript-profunctor
#Profunctor Source
class Profunctor p where
A Profunctor
is a Functor
from the pair category (Type^op, Type)
to Type
.
In other words, a Profunctor
is a type constructor of two type
arguments, which is contravariant in its first argument and covariant
in its second argument.
The dimap
function can be used to map functions over both arguments
simultaneously.
A straightforward example of a profunctor is the function arrow (->)
.
Laws:
- Identity:
dimap id id = id
- Composition:
dimap f1 g1 <<< dimap f2 g2 = dimap (f1 >>> f2) (g1 <<< g2)
Members
dimap :: forall d c b a. (a -> b) -> (c -> d) -> p b c -> p a d
Instances
#lmap Source
lmap :: forall p c b a. Profunctor p => (a -> b) -> p b c -> p a c
Map a function over the (contravariant) first type argument only.
#rmap Source
rmap :: forall p c b a. Profunctor p => (b -> c) -> p a b -> p a c
Map a function over the (covariant) second type argument only.
#arr Source
arr :: forall p b a. Category p => Profunctor p => (a -> b) -> p a b
Lift a pure function into any Profunctor
which is also a Category
.
#unwrapIso Source
unwrapIso :: forall a t p. Profunctor p => Newtype t a => p t t -> p a a
#wrapIso Source
wrapIso :: forall a t p. Profunctor p => Newtype t a => (t -> a) -> p a a -> p t t