Copyright | (C) 2011-2015 Edward Kmett |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Stability | provisional |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
For a good explanation of profunctors in Haskell see Dan Piponi's article:
http://blog.sigfpe.com/2011/07/profunctors-in-haskell.html
For more information on strength and costrength, see:
http://comonad.com/reader/2008/deriving-strength-from-laziness/
Synopsis
- class Profunctor p where
- class Profunctor p => Strong p where
- uncurry' :: Strong p => p a (b -> c) -> p (a, b) c
- class Profunctor p => Choice p where
-
class
Profunctor
p =>
Closed
p
where
- closed :: p a b -> p (x -> a) (x -> b)
- curry' :: Closed p => p (a, b) c -> p a (b -> c)
- class ( Traversing p, Closed p) => Mapping p where
- class Profunctor p => Costrong p where
- class Profunctor p => Cochoice p where
-
newtype
Star
f d c =
Star
{
- runStar :: d -> f c
-
newtype
Costar
f d c =
Costar
{
- runCostar :: f d -> c
-
newtype
WrappedArrow
p a b =
WrapArrow
{
- unwrapArrow :: p a b
-
newtype
Forget
r a b =
Forget
{
- runForget :: a -> r
- type (:->) p q = forall a b. p a b -> q a b
Profunctors
class Profunctor p where Source #
Formally, the class
Profunctor
represents a profunctor
from
Hask
->
Hask
.
Intuitively it is a bifunctor where the first argument is contravariant and the second argument is covariant.
You can define a
Profunctor
by either defining
dimap
or by defining both
lmap
and
rmap
.
If you supply
dimap
, you should ensure that:
dimap
id
id
≡id
If you supply
lmap
and
rmap
, ensure:
lmap
id
≡id
rmap
id
≡id
If you supply both, you should also ensure:
dimap
f g ≡lmap
f.
rmap
g
These ensure by parametricity:
dimap
(f.
g) (h.
i) ≡dimap
g h.
dimap
f ilmap
(f.
g) ≡lmap
g.
lmap
frmap
(f.
g) ≡rmap
f.
rmap
g
dimap :: (a -> b) -> (c -> d) -> p b c -> p a d Source #
Instances
Monad m => Profunctor ( Kleisli m) Source # | |
Defined in Data.Profunctor.Unsafe dimap :: (a -> b) -> (c -> d) -> Kleisli m b c -> Kleisli m a d Source # lmap :: (a -> b) -> Kleisli m b c -> Kleisli m a c Source # rmap :: (b -> c) -> Kleisli m a b -> Kleisli m a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Kleisli m a b -> Kleisli m a c Source # (.#) :: forall a b c q. Coercible b a => Kleisli m b c -> q a b -> Kleisli m a c Source # |
|
Profunctor ( Tagged :: Type -> Type -> Type ) Source # | |
Defined in Data.Profunctor.Unsafe dimap :: (a -> b) -> (c -> d) -> Tagged b c -> Tagged a d Source # lmap :: (a -> b) -> Tagged b c -> Tagged a c Source # rmap :: (b -> c) -> Tagged a b -> Tagged a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Tagged a b -> Tagged a c Source # (.#) :: forall a b c q. Coercible b a => Tagged b c -> q a b -> Tagged a c Source # |
|
Profunctor ( Copastro p) Source # | |
Defined in Data.Profunctor.Strong dimap :: (a -> b) -> (c -> d) -> Copastro p b c -> Copastro p a d Source # lmap :: (a -> b) -> Copastro p b c -> Copastro p a c Source # rmap :: (b -> c) -> Copastro p a b -> Copastro p a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Copastro p a b -> Copastro p a c Source # (.#) :: forall a b c q. Coercible b a => Copastro p b c -> q a b -> Copastro p a c Source # |
|
Profunctor ( Cotambara p) Source # | |
Defined in Data.Profunctor.Strong dimap :: (a -> b) -> (c -> d) -> Cotambara p b c -> Cotambara p a d Source # lmap :: (a -> b) -> Cotambara p b c -> Cotambara p a c Source # rmap :: (b -> c) -> Cotambara p a b -> Cotambara p a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Cotambara p a b -> Cotambara p a c Source # (.#) :: forall a b c q. Coercible b a => Cotambara p b c -> q a b -> Cotambara p a c Source # |
|
Profunctor ( Pastro p) Source # | |
Defined in Data.Profunctor.Strong dimap :: (a -> b) -> (c -> d) -> Pastro p b c -> Pastro p a d Source # lmap :: (a -> b) -> Pastro p b c -> Pastro p a c Source # rmap :: (b -> c) -> Pastro p a b -> Pastro p a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Pastro p a b -> Pastro p a c Source # (.#) :: forall a b c q. Coercible b a => Pastro p b c -> q a b -> Pastro p a c Source # |
|
Profunctor p => Profunctor ( Tambara p) Source # | |
Defined in Data.Profunctor.Strong dimap :: (a -> b) -> (c -> d) -> Tambara p b c -> Tambara p a d Source # lmap :: (a -> b) -> Tambara p b c -> Tambara p a c Source # rmap :: (b -> c) -> Tambara p a b -> Tambara p a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Tambara p a b -> Tambara p a c Source # (.#) :: forall a b c q. Coercible b a => Tambara p b c -> q a b -> Tambara p a c Source # |
|
Profunctor ( Environment p) Source # | |
Defined in Data.Profunctor.Closed dimap :: (a -> b) -> (c -> d) -> Environment p b c -> Environment p a d Source # lmap :: (a -> b) -> Environment p b c -> Environment p a c Source # rmap :: (b -> c) -> Environment p a b -> Environment p a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Environment p a b -> Environment p a c Source # (.#) :: forall a b c q. Coercible b a => Environment p b c -> q a b -> Environment p a c Source # |
|
Profunctor p => Profunctor ( Closure p) Source # | |
Defined in Data.Profunctor.Closed dimap :: (a -> b) -> (c -> d) -> Closure p b c -> Closure p a d Source # lmap :: (a -> b) -> Closure p b c -> Closure p a c Source # rmap :: (b -> c) -> Closure p a b -> Closure p a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Closure p a b -> Closure p a c Source # (.#) :: forall a b c q. Coercible b a => Closure p b c -> q a b -> Closure p a c Source # |
|
Profunctor ( CopastroSum p) Source # | |
Defined in Data.Profunctor.Choice dimap :: (a -> b) -> (c -> d) -> CopastroSum p b c -> CopastroSum p a d Source # lmap :: (a -> b) -> CopastroSum p b c -> CopastroSum p a c Source # rmap :: (b -> c) -> CopastroSum p a b -> CopastroSum p a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> CopastroSum p a b -> CopastroSum p a c Source # (.#) :: forall a b c q. Coercible b a => CopastroSum p b c -> q a b -> CopastroSum p a c Source # |
|
Profunctor ( CotambaraSum p) Source # | |
Defined in Data.Profunctor.Choice dimap :: (a -> b) -> (c -> d) -> CotambaraSum p b c -> CotambaraSum p a d Source # lmap :: (a -> b) -> CotambaraSum p b c -> CotambaraSum p a c Source # rmap :: (b -> c) -> CotambaraSum p a b -> CotambaraSum p a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> CotambaraSum p a b -> CotambaraSum p a c Source # (.#) :: forall a b c q. Coercible b a => CotambaraSum p b c -> q a b -> CotambaraSum p a c Source # |
|
Profunctor ( PastroSum p) Source # | |
Defined in Data.Profunctor.Choice dimap :: (a -> b) -> (c -> d) -> PastroSum p b c -> PastroSum p a d Source # lmap :: (a -> b) -> PastroSum p b c -> PastroSum p a c Source # rmap :: (b -> c) -> PastroSum p a b -> PastroSum p a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> PastroSum p a b -> PastroSum p a c Source # (.#) :: forall a b c q. Coercible b a => PastroSum p b c -> q a b -> PastroSum p a c Source # |
|
Profunctor p => Profunctor ( TambaraSum p) Source # | |
Defined in Data.Profunctor.Choice dimap :: (a -> b) -> (c -> d) -> TambaraSum p b c -> TambaraSum p a d Source # lmap :: (a -> b) -> TambaraSum p b c -> TambaraSum p a c Source # rmap :: (b -> c) -> TambaraSum p a b -> TambaraSum p a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> TambaraSum p a b -> TambaraSum p a c Source # (.#) :: forall a b c q. Coercible b a => TambaraSum p b c -> q a b -> TambaraSum p a c Source # |
|
Profunctor ( FreeTraversing p) Source # | |
Defined in Data.Profunctor.Traversing dimap :: (a -> b) -> (c -> d) -> FreeTraversing p b c -> FreeTraversing p a d Source # lmap :: (a -> b) -> FreeTraversing p b c -> FreeTraversing p a c Source # rmap :: (b -> c) -> FreeTraversing p a b -> FreeTraversing p a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> FreeTraversing p a b -> FreeTraversing p a c Source # (.#) :: forall a b c q. Coercible b a => FreeTraversing p b c -> q a b -> FreeTraversing p a c Source # |
|
Profunctor p => Profunctor ( CofreeTraversing p) Source # | |
Defined in Data.Profunctor.Traversing dimap :: (a -> b) -> (c -> d) -> CofreeTraversing p b c -> CofreeTraversing p a d Source # lmap :: (a -> b) -> CofreeTraversing p b c -> CofreeTraversing p a c Source # rmap :: (b -> c) -> CofreeTraversing p a b -> CofreeTraversing p a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> CofreeTraversing p a b -> CofreeTraversing p a c Source # (.#) :: forall a b c q. Coercible b a => CofreeTraversing p b c -> q a b -> CofreeTraversing p a c Source # |
|
Profunctor ( FreeMapping p) Source # | |
Defined in Data.Profunctor.Mapping dimap :: (a -> b) -> (c -> d) -> FreeMapping p b c -> FreeMapping p a d Source # lmap :: (a -> b) -> FreeMapping p b c -> FreeMapping p a c Source # rmap :: (b -> c) -> FreeMapping p a b -> FreeMapping p a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> FreeMapping p a b -> FreeMapping p a c Source # (.#) :: forall a b c q. Coercible b a => FreeMapping p b c -> q a b -> FreeMapping p a c Source # |
|
Profunctor p => Profunctor ( CofreeMapping p) Source # | |
Defined in Data.Profunctor.Mapping dimap :: (a -> b) -> (c -> d) -> CofreeMapping p b c -> CofreeMapping p a d Source # lmap :: (a -> b) -> CofreeMapping p b c -> CofreeMapping p a c Source # rmap :: (b -> c) -> CofreeMapping p a b -> CofreeMapping p a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> CofreeMapping p a b -> CofreeMapping p a c Source # (.#) :: forall a b c q. Coercible b a => CofreeMapping p b c -> q a b -> CofreeMapping p a c Source # |
|
Profunctor ( Coyoneda p) Source # | |
Defined in Data.Profunctor.Yoneda dimap :: (a -> b) -> (c -> d) -> Coyoneda p b c -> Coyoneda p a d Source # lmap :: (a -> b) -> Coyoneda p b c -> Coyoneda p a c Source # rmap :: (b -> c) -> Coyoneda p a b -> Coyoneda p a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Coyoneda p a b -> Coyoneda p a c Source # (.#) :: forall a b c q. Coercible b a => Coyoneda p b c -> q a b -> Coyoneda p a c Source # |
|
Profunctor ( Yoneda p) Source # | |
Defined in Data.Profunctor.Yoneda dimap :: (a -> b) -> (c -> d) -> Yoneda p b c -> Yoneda p a d Source # lmap :: (a -> b) -> Yoneda p b c -> Yoneda p a c Source # rmap :: (b -> c) -> Yoneda p a b -> Yoneda p a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Yoneda p a b -> Yoneda p a c Source # (.#) :: forall a b c q. Coercible b a => Yoneda p b c -> q a b -> Yoneda p a c Source # |
|
Profunctor ((->) :: Type -> Type -> Type ) Source # | |
Defined in Data.Profunctor.Unsafe dimap :: (a -> b) -> (c -> d) -> (b -> c) -> a -> d Source # lmap :: (a -> b) -> (b -> c) -> a -> c Source # rmap :: (b -> c) -> (a -> b) -> a -> c Source # (#.) :: forall a b c q. Coercible c b => q b c -> (a -> b) -> a -> c Source # (.#) :: forall a b c q. Coercible b a => (b -> c) -> q a b -> a -> c Source # |
|
Functor w => Profunctor ( Cokleisli w) Source # | |
Defined in Data.Profunctor.Unsafe dimap :: (a -> b) -> (c -> d) -> Cokleisli w b c -> Cokleisli w a d Source # lmap :: (a -> b) -> Cokleisli w b c -> Cokleisli w a c Source # rmap :: (b -> c) -> Cokleisli w a b -> Cokleisli w a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Cokleisli w a b -> Cokleisli w a c Source # (.#) :: forall a b c q. Coercible b a => Cokleisli w b c -> q a b -> Cokleisli w a c Source # |
|
Profunctor ( Forget r :: Type -> Type -> Type ) Source # | |
Defined in Data.Profunctor.Types dimap :: (a -> b) -> (c -> d) -> Forget r b c -> Forget r a d Source # lmap :: (a -> b) -> Forget r b c -> Forget r a c Source # rmap :: (b -> c) -> Forget r a b -> Forget r a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Forget r a b -> Forget r a c Source # (.#) :: forall a b c q. Coercible b a => Forget r b c -> q a b -> Forget r a c Source # |
|
Functor f => Profunctor ( Costar f) Source # | |
Defined in Data.Profunctor.Types dimap :: (a -> b) -> (c -> d) -> Costar f b c -> Costar f a d Source # lmap :: (a -> b) -> Costar f b c -> Costar f a c Source # rmap :: (b -> c) -> Costar f a b -> Costar f a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Costar f a b -> Costar f a c Source # (.#) :: forall a b c q. Coercible b a => Costar f b c -> q a b -> Costar f a c Source # |
|
Functor f => Profunctor ( Star f) Source # | |
Defined in Data.Profunctor.Types dimap :: (a -> b) -> (c -> d) -> Star f b c -> Star f a d Source # lmap :: (a -> b) -> Star f b c -> Star f a c Source # rmap :: (b -> c) -> Star f a b -> Star f a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Star f a b -> Star f a c Source # (.#) :: forall a b c q. Coercible b a => Star f b c -> q a b -> Star f a c Source # |
|
Functor f => Profunctor ( Joker f :: Type -> Type -> Type ) Source # | |
Defined in Data.Profunctor.Unsafe dimap :: (a -> b) -> (c -> d) -> Joker f b c -> Joker f a d Source # lmap :: (a -> b) -> Joker f b c -> Joker f a c Source # rmap :: (b -> c) -> Joker f a b -> Joker f a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Joker f a b -> Joker f a c Source # (.#) :: forall a b c q. Coercible b a => Joker f b c -> q a b -> Joker f a c Source # |
|
Contravariant f => Profunctor ( Clown f :: Type -> Type -> Type ) Source # | |
Defined in Data.Profunctor.Unsafe dimap :: (a -> b) -> (c -> d) -> Clown f b c -> Clown f a d Source # lmap :: (a -> b) -> Clown f b c -> Clown f a c Source # rmap :: (b -> c) -> Clown f a b -> Clown f a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Clown f a b -> Clown f a c Source # (.#) :: forall a b c q. Coercible b a => Clown f b c -> q a b -> Clown f a c Source # |
|
Arrow p => Profunctor ( WrappedArrow p) Source # | |
Defined in Data.Profunctor.Types dimap :: (a -> b) -> (c -> d) -> WrappedArrow p b c -> WrappedArrow p a d Source # lmap :: (a -> b) -> WrappedArrow p b c -> WrappedArrow p a c Source # rmap :: (b -> c) -> WrappedArrow p a b -> WrappedArrow p a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> WrappedArrow p a b -> WrappedArrow p a c Source # (.#) :: forall a b c q. Coercible b a => WrappedArrow p b c -> q a b -> WrappedArrow p a c Source # |
|
Profunctor p => Profunctor ( Codensity p) Source # | |
Defined in Data.Profunctor.Ran dimap :: (a -> b) -> (c -> d) -> Codensity p b c -> Codensity p a d Source # lmap :: (a -> b) -> Codensity p b c -> Codensity p a c Source # rmap :: (b -> c) -> Codensity p a b -> Codensity p a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Codensity p a b -> Codensity p a c Source # (.#) :: forall a b c q. Coercible b a => Codensity p b c -> q a b -> Codensity p a c Source # |
|
( Profunctor p, Profunctor q) => Profunctor ( Sum p q) Source # | |
Defined in Data.Profunctor.Unsafe dimap :: (a -> b) -> (c -> d) -> Sum p q b c -> Sum p q a d Source # lmap :: (a -> b) -> Sum p q b c -> Sum p q a c Source # rmap :: (b -> c) -> Sum p q a b -> Sum p q a c Source # (#.) :: forall a b c q0. Coercible c b => q0 b c -> Sum p q a b -> Sum p q a c Source # (.#) :: forall a b c q0. Coercible b a => Sum p q b c -> q0 a b -> Sum p q a c Source # |
|
( Profunctor p, Profunctor q) => Profunctor ( Product p q) Source # | |
Defined in Data.Profunctor.Unsafe dimap :: (a -> b) -> (c -> d) -> Product p q b c -> Product p q a d Source # lmap :: (a -> b) -> Product p q b c -> Product p q a c Source # rmap :: (b -> c) -> Product p q a b -> Product p q a c Source # (#.) :: forall a b c q0. Coercible c b => q0 b c -> Product p q a b -> Product p q a c Source # (.#) :: forall a b c q0. Coercible b a => Product p q b c -> q0 a b -> Product p q a c Source # |
|
( Functor f, Profunctor p) => Profunctor ( Tannen f p) Source # | |
Defined in Data.Profunctor.Unsafe dimap :: (a -> b) -> (c -> d) -> Tannen f p b c -> Tannen f p a d Source # lmap :: (a -> b) -> Tannen f p b c -> Tannen f p a c Source # rmap :: (b -> c) -> Tannen f p a b -> Tannen f p a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Tannen f p a b -> Tannen f p a c Source # (.#) :: forall a b c q. Coercible b a => Tannen f p b c -> q a b -> Tannen f p a c Source # |
|
( Profunctor p, Profunctor q) => Profunctor ( Rift p q) Source # | |
Defined in Data.Profunctor.Composition 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, Profunctor q) => Profunctor ( Procompose p q) Source # | |
Defined in Data.Profunctor.Composition 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 # |
|
( Profunctor p, Profunctor q) => Profunctor ( Ran p q) Source # | |
Defined in Data.Profunctor.Ran dimap :: (a -> b) -> (c -> d) -> Ran p q b c -> Ran p q a d Source # lmap :: (a -> b) -> Ran p q b c -> Ran p q a c Source # rmap :: (b -> c) -> Ran p q a b -> Ran p q a c Source # (#.) :: forall a b c q0. Coercible c b => q0 b c -> Ran p q a b -> Ran p q a c Source # (.#) :: forall a b c q0. Coercible b a => Ran p q b c -> q0 a b -> Ran p q a c Source # |
|
( Functor f, Profunctor p) => Profunctor ( Cayley f p) Source # | |
Defined in Data.Profunctor.Cayley dimap :: (a -> b) -> (c -> d) -> Cayley f p b c -> Cayley f p a d Source # lmap :: (a -> b) -> Cayley f p b c -> Cayley f p a c Source # rmap :: (b -> c) -> Cayley f p a b -> Cayley f p a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Cayley f p a b -> Cayley f p a c Source # (.#) :: forall a b c q. Coercible b a => Cayley f p b c -> q a b -> Cayley f p a c Source # |
|
( Profunctor p, Functor f, Functor g) => Profunctor ( Biff p f g) Source # | |
Defined in Data.Profunctor.Unsafe dimap :: (a -> b) -> (c -> d) -> Biff p f g b c -> Biff p f g a d Source # lmap :: (a -> b) -> Biff p f g b c -> Biff p f g a c Source # rmap :: (b -> c) -> Biff p f g a b -> Biff p f g a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Biff p f g a b -> Biff p f g a c Source # (.#) :: forall a b c q. Coercible b a => Biff p f g b c -> q a b -> Biff p f g a c Source # |
Profunctorial Strength
class Profunctor p => Strong p where Source #
Generalizing
Star
of a strong
Functor
Note:
Every
Functor
in Haskell is strong with respect to
(,)
.
This describes profunctor strength with respect to the product structure of Hask.
Instances
class Profunctor p => Choice p where Source #
The generalization of
Costar
of
Functor
that is strong with respect
to
Either
.
Note: This is also a notion of strength, except with regards to another monoidal structure that we can choose to equip Hask with: the cocartesian coproduct.
left' :: p a b -> p ( Either a c) ( Either b c) Source #
Laws:
left'
≡dimap
swapE swapE.
right'
where swapE ::Either
a b ->Either
b a swapE =either
Right
Left
rmap
Left
≡lmap
Left
.
left'
lmap
(right
f).
left'
≡rmap
(right
f).
left'
left'
.
left'
≡dimap
assocE unassocE.
left'
where assocE ::Either
(Either
a b) c ->Either
a (Either
b c) assocE (Left
(Left
a)) =Left
a assocE (Left
(Right
b)) =Right
(Left
b) assocE (Right
c) =Right
(Right
c) unassocE ::Either
a (Either
b c) ->Either
(Either
a b) c unassocE (Left
a) =Left
(Left
a) unassocE (Right
(Left
b)) =Left
(Right
b) unassocE (Right
(Right
c)) =Right
c
right' :: p a b -> p ( Either c a) ( Either c b) Source #
Laws:
right'
≡dimap
swapE swapE.
left'
where swapE ::Either
a b ->Either
b a swapE =either
Right
Left
rmap
Right
≡lmap
Right
.
right'
lmap
(left
f).
right'
≡rmap
(left
f).
right'
right'
.
right'
≡dimap
unassocE assocE.
right'
where assocE ::Either
(Either
a b) c ->Either
a (Either
b c) assocE (Left
(Left
a)) =Left
a assocE (Left
(Right
b)) =Right
(Left
b) assocE (Right
c) =Right
(Right
c) unassocE ::Either
a (Either
b c) ->Either
(Either
a b) c unassocE (Left
a) =Left
(Left
a) unassocE (Right
(Left
b)) =Left
(Right
b) unassocE (Right
(Right
c)) =Right
c
Instances
Closed
class Profunctor p => Closed p where Source #
A strong profunctor allows the monoidal structure to pass through.
A closed profunctor allows the closed structure to pass through.
Instances
class ( Traversing p, Closed p) => Mapping p where Source #
Nothing
Instances
Profunctorial Costrength
class Profunctor p => Costrong p where Source #
Instances
class Profunctor p => Cochoice p where Source #
unleft :: p ( Either a d) ( Either b d) -> p a b Source #
Laws:
unleft
≡unright
.
dimap
swapE swapE where swapE ::Either
a b ->Either
b a swapE =either
Right
Left
rmap
(either
id
absurd
) ≡unleft
.
lmap
(either
id
absurd
)unfirst
.
rmap
(second
f) ≡unfirst
.
lmap
(second
f)unleft
.
unleft
≡unleft
.
dimap
assocE unassocE where assocE ::Either
(Either
a b) c ->Either
a (Either
b c) assocE (Left
(Left
a)) =Left
a assocE (Left
(Right
b)) =Right
(Left
b) assocE (Right
c) =Right
(Right
c) unassocE ::Either
a (Either
b c) ->Either
(Either
a b) c unassocE (Left
a) =Left
(Left
a) unassocE (Right
(Left
b)) =Left
(Right
b) unassocE (Right
(Right
c)) =Right
c
unright :: p ( Either d a) ( Either d b) -> p a b Source #
Laws:
unright
≡unleft
.
dimap
swapE swapE where swapE ::Either
a b ->Either
b a swapE =either
Right
Left
rmap
(either
absurd
id
) ≡unright
.
lmap
(either
absurd
id
)unsecond
.
rmap
(first
f) ≡unsecond
.
lmap
(first
f)unright
.
unright
≡unright
.
dimap
unassocE assocE where assocE ::Either
(Either
a b) c ->Either
a (Either
b c) assocE (Left
(Left
a)) =Left
a assocE (Left
(Right
b)) =Right
(Left
b) assocE (Right
c) =Right
(Right
c) unassocE ::Either
a (Either
b c) ->Either
(Either
a b) c unassocE (Left
a) =Left
(Left
a) unassocE (Right
(Left
b)) =Left
(Right
b) unassocE (Right
(Right
c)) =Right
c
Instances
Cochoice ( CopastroSum p) Source # | |
Defined in Data.Profunctor.Choice unleft :: CopastroSum p ( Either a d) ( Either b d) -> CopastroSum p a b Source # unright :: CopastroSum p ( Either d a) ( Either d b) -> CopastroSum p a b Source # |
|
Cochoice ( CotambaraSum p) Source # | |
Defined in Data.Profunctor.Choice unleft :: CotambaraSum p ( Either a d) ( Either b d) -> CotambaraSum p a b Source # unright :: CotambaraSum p ( Either d a) ( Either d b) -> CotambaraSum p a b Source # |
|
Cochoice p => Cochoice ( Coyoneda p) Source # | |
Cochoice p => Cochoice ( Yoneda p) Source # | |
Cochoice ((->) :: Type -> Type -> Type ) Source # | |
Cochoice ( Forget r :: Type -> Type -> Type ) Source # | |
Applicative f => Cochoice ( Costar f) Source # | |
Traversable f => Cochoice ( Star f) Source # | |
( Cochoice p, Cochoice q) => Cochoice ( Sum p q) Source # | |
( Cochoice p, Cochoice q) => Cochoice ( Product p q) Source # | |
( Functor f, Cochoice p) => Cochoice ( Tannen f p) Source # | |
( Functor f, Cochoice p) => Cochoice ( Cayley f p) Source # | |
Common Profunctors
Lift a
Functor
into a
Profunctor
(forwards).
Star
has a polymorphic kind since
5.6
.
Instances
Lift a
Functor
into a
Profunctor
(backwards).
Costar
has a polymorphic kind since
5.6
.
Instances
Functor f => Profunctor ( Costar f) Source # | |
Defined in Data.Profunctor.Types dimap :: (a -> b) -> (c -> d) -> Costar f b c -> Costar f a d Source # lmap :: (a -> b) -> Costar f b c -> Costar f a c Source # rmap :: (b -> c) -> Costar f a b -> Costar f a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Costar f a b -> Costar f a c Source # (.#) :: forall a b c q. Coercible b a => Costar f b c -> q a b -> Costar f a c Source # |
|
Functor f => Costrong ( Costar f) Source # | |
Functor f => Closed ( Costar f) Source # | |
Applicative f => Cochoice ( Costar f) Source # | |
Functor f => Corepresentable ( Costar f) Source # | |
Functor f => Cosieve ( Costar f) f Source # | |
Defined in Data.Profunctor.Sieve |
|
Monad ( Costar f a) Source # | |
Functor ( Costar f a) Source # | |
Applicative ( Costar f a) Source # | |
Defined in Data.Profunctor.Types pure :: a0 -> Costar f a a0 Source # (<*>) :: Costar f a (a0 -> b) -> Costar f a a0 -> Costar f a b Source # liftA2 :: (a0 -> b -> c) -> Costar f a a0 -> Costar f a b -> Costar f a c Source # (*>) :: Costar f a a0 -> Costar f a b -> Costar f a b Source # (<*) :: Costar f a a0 -> Costar f a b -> Costar f a a0 Source # |
|
Distributive ( Costar f d) Source # | |
Defined in Data.Profunctor.Types distribute :: Functor f0 => f0 ( Costar f d a) -> Costar f d (f0 a) Source # collect :: Functor f0 => (a -> Costar f d b) -> f0 a -> Costar f d (f0 b) Source # distributeM :: Monad m => m ( Costar f d a) -> Costar f d (m a) Source # collectM :: Monad m => (a -> Costar f d b) -> m a -> Costar f d (m b) Source # |
|
type Corep ( Costar f) Source # | |
Defined in Data.Profunctor.Rep |
newtype WrappedArrow p a b Source #
Wrap an arrow for use as a
Profunctor
.
WrappedArrow
has a polymorphic kind since
5.6
.
WrapArrow | |
|
Instances
Forget
has a polymorphic kind since
5.6
.
Instances
Profunctor ( Forget r :: Type -> Type -> Type ) Source # | |
Defined in Data.Profunctor.Types dimap :: (a -> b) -> (c -> d) -> Forget r b c -> Forget r a d Source # lmap :: (a -> b) -> Forget r b c -> Forget r a c Source # rmap :: (b -> c) -> Forget r a b -> Forget r a c Source # (#.) :: forall a b c q. Coercible c b => q b c -> Forget r a b -> Forget r a c Source # (.#) :: forall a b c q. Coercible b a => Forget r b c -> q a b -> Forget r a c Source # |
|
Strong ( Forget r :: Type -> Type -> Type ) Source # | |
Cochoice ( Forget r :: Type -> Type -> Type ) Source # | |
Monoid r => Choice ( Forget r :: Type -> Type -> Type ) Source # | |
Monoid m => Traversing ( Forget m :: Type -> Type -> Type ) Source # | |
Defined in Data.Profunctor.Traversing |
|
Representable ( Forget r :: Type -> Type -> Type ) Source # | |
Sieve ( Forget r :: Type -> Type -> Type ) ( Const r :: Type -> Type ) Source # | |
Functor ( Forget r a :: Type -> Type ) Source # | |
Foldable ( Forget r a :: Type -> Type ) Source # | |
Defined in Data.Profunctor.Types fold :: Monoid m => Forget r a m -> m Source # foldMap :: Monoid m => (a0 -> m) -> Forget r a a0 -> m Source # foldMap' :: Monoid m => (a0 -> m) -> Forget r a a0 -> m Source # foldr :: (a0 -> b -> b) -> b -> Forget r a a0 -> b Source # foldr' :: (a0 -> b -> b) -> b -> Forget r a a0 -> b Source # foldl :: (b -> a0 -> b) -> b -> Forget r a a0 -> b Source # foldl' :: (b -> a0 -> b) -> b -> Forget r a a0 -> b Source # foldr1 :: (a0 -> a0 -> a0) -> Forget r a a0 -> a0 Source # foldl1 :: (a0 -> a0 -> a0) -> Forget r a a0 -> a0 Source # toList :: Forget r a a0 -> [a0] Source # null :: Forget r a a0 -> Bool Source # length :: Forget r a a0 -> Int Source # elem :: Eq a0 => a0 -> Forget r a a0 -> Bool Source # maximum :: Ord a0 => Forget r a a0 -> a0 Source # minimum :: Ord a0 => Forget r a a0 -> a0 Source # |
|
Traversable ( Forget r a :: Type -> Type ) Source # | |
Defined in Data.Profunctor.Types traverse :: Applicative f => (a0 -> f b) -> Forget r a a0 -> f ( Forget r a b) Source # sequenceA :: Applicative f => Forget r a (f a0) -> f ( Forget r a a0) Source # mapM :: Monad m => (a0 -> m b) -> Forget r a a0 -> m ( Forget r a b) Source # sequence :: Monad m => Forget r a (m a0) -> m ( Forget r a a0) Source # |
|
Contravariant ( Forget r a :: Type -> Type ) Source # | |
Semigroup r => Semigroup ( Forget r a b) Source # |
Via
Since: 5.6.2 |
Monoid r => Monoid ( Forget r a b) Source # |
Via
Since: 5.6.2 |
type Rep ( Forget r :: Type -> Type -> Type ) Source # | |