profunctors-5.2: Profunctors

Copyright | (C) 2014-2015 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | provisional
Portability | Rank2Types
Safe Haskell | None
Language | Haskell2010

Data.Profunctor.Choice

Contents

- Strength
- Costrength

Description

Synopsis

- class Profunctor p => Choice p where
- newtype TambaraSum p a b = TambaraSum {
  - runTambaraSum :: forall c. p (Either a c) (Either b c)
  }
- tambaraSum :: Choice p => (p :-> q) -> p :-> TambaraSum q
- untambaraSum :: Profunctor q => (p :-> TambaraSum q) -> p :-> q
- data PastroSum p a b where
  - PastroSum :: (Either y z -> b) -> p x y -> (a -> Either x z) -> PastroSum p a b
- class Profunctor p => Cochoice p where
- data CotambaraSum q a b where
  - CotambaraSum :: Cochoice r => (r :-> q) -> r a b -> CotambaraSum q a b
- cotambaraSum :: Cochoice p => (p :-> q) -> p :-> CotambaraSum q
- uncotambaraSum :: Profunctor q => (p :-> CotambaraSum q) -> p :-> q
- newtype CopastroSum p a b = CopastroSum {
  - runCopastroSum :: forall r. Cochoice r => (forall x y. p x y -> r x y) -> r a b
  }

# Strength

class Profunctor p => Choice p where #

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.

Minimal complete definition

left' | right'

Methods

left' :: p a b -> p (Either a c) (Either b c) #

right' :: p a b -> p (Either c a) (Either c b) #

Instances

Choice (->) # |
Methods left' :: (a -> b) -> Either a c -> Either b c # right' :: (a -> b) -> Either c a -> Either c b #
Monad m => Choice (Kleisli m) # |
Methods left' :: Kleisli m a b -> Kleisli m (Either a c) (Either b c) # right' :: Kleisli m a b -> Kleisli m (Either c a) (Either c b) #
Comonad w => Choice (Cokleisli w) # | `extract` approximates `costrength`
Methods left' :: Cokleisli w a b -> Cokleisli w (Either a c) (Either b c) # right' :: Cokleisli w a b -> Cokleisli w (Either c a) (Either c b) #
Choice (Tagged *) # |
Methods left' :: Tagged * a b -> Tagged * (Either a c) (Either b c) # right' :: Tagged * a b -> Tagged * (Either c a) (Either c b) #
Monoid r => Choice (Forget r) # |
Methods left' :: Forget r a b -> Forget r (Either a c) (Either b c) # right' :: Forget r a b -> Forget r (Either c a) (Either c b) #
ArrowChoice p => Choice (WrappedArrow p) # |
Methods left' :: WrappedArrow p a b -> WrappedArrow p (Either a c) (Either b c) # right' :: WrappedArrow p a b -> WrappedArrow p (Either c a) (Either c b) #
Traversable w => Choice (Costar w) # |
Methods left' :: Costar w a b -> Costar w (Either a c) (Either b c) # right' :: Costar w a b -> Costar w (Either c a) (Either c b) #
Applicative f => Choice (Star f) # |
Methods left' :: Star f a b -> Star f (Either a c) (Either b c) # right' :: Star f a b -> Star f (Either c a) (Either c b) #
Choice p => Choice (Tambara p) # |
Methods left' :: Tambara p a b -> Tambara p (Either a c) (Either b c) # right' :: Tambara p a b -> Tambara p (Either c a) (Either c b) #
Choice (PastroSum p) # |
Methods left' :: PastroSum p a b -> PastroSum p (Either a c) (Either b c) # right' :: PastroSum p a b -> PastroSum p (Either c a) (Either c b) #
Profunctor p => Choice (TambaraSum p) # |
Methods left' :: TambaraSum p a b -> TambaraSum p (Either a c) (Either b c) # right' :: TambaraSum p a b -> TambaraSum p (Either c a) (Either c b) #
Choice (FreeTraversing p) # |
Methods left' :: FreeTraversing p a b -> FreeTraversing p (Either a c) (Either b c) # right' :: FreeTraversing p a b -> FreeTraversing p (Either c a) (Either c b) #
Profunctor p => Choice (CofreeTraversing p) # |
Methods left' :: CofreeTraversing p a b -> CofreeTraversing p (Either a c) (Either b c) # right' :: CofreeTraversing p a b -> CofreeTraversing p (Either c a) (Either c b) #
Choice (FreeMapping p) # |
Methods left' :: FreeMapping p a b -> FreeMapping p (Either a c) (Either b c) # right' :: FreeMapping p a b -> FreeMapping p (Either c a) (Either c b) #
Profunctor p => Choice (CofreeMapping p) # |
Methods left' :: CofreeMapping p a b -> CofreeMapping p (Either a c) (Either b c) # right' :: CofreeMapping p a b -> CofreeMapping p (Either c a) (Either c b) #
(Functor f, Choice p) => Choice (Cayley f p) # |
Methods left' :: Cayley f p a b -> Cayley f p (Either a c) (Either b c) # right' :: Cayley f p a b -> Cayley f p (Either c a) (Either c b) #
(Choice p, Choice q) => Choice (Procompose p q) # |
Methods left' :: Procompose p q a b -> Procompose p q (Either a c) (Either b c) # right' :: Procompose p q a b -> Procompose p q (Either c a) (Either c b) #
Functor f => Choice (Joker * * f) # |
Methods left' :: Joker * * f a b -> Joker * * f (Either a c) (Either b c) # right' :: Joker * * f a b -> Joker * * f (Either c a) (Either c b) #
(Choice p, Choice q) => Choice (Product * * p q) # |
Methods left' :: Product * * p q a b -> Product * * p q (Either a c) (Either b c) # right' :: Product * * p q a b -> Product * * p q (Either c a) (Either c b) #
(Functor f, Choice p) => Choice (Tannen * * * f p) # |
Methods left' :: Tannen * * * f p a b -> Tannen * * * f p (Either a c) (Either b c) # right' :: Tannen * * * f p a b -> Tannen * * * f p (Either c a) (Either c b) #

newtype TambaraSum p a b #

TambaraSum is cofreely adjoins strength with respect to Either.

Note: this is not dual to `Tambara`. It is `Tambara` with respect to a different tensor.

Constructors

TambaraSum |
Fields runTambaraSum :: forall c. p (Either a c) (Either b c)

Instances

ProfunctorComonad TambaraSum # |
Methods proextract :: Profunctor p => TambaraSum p :-> p # produplicate :: Profunctor p => TambaraSum p :-> TambaraSum (TambaraSum p) #
ProfunctorFunctor TambaraSum # |
Methods promap :: Profunctor p => (p :-> q) -> TambaraSum p :-> TambaraSum q #
ProfunctorAdjunction PastroSum TambaraSum # |
Methods unit :: Profunctor p => p :-> TambaraSum (PastroSum p) # counit :: Profunctor p => PastroSum (TambaraSum p) :-> p #
Profunctor p => Profunctor (TambaraSum p) # |
Methods dimap :: (a -> b) -> (c -> d) -> TambaraSum p b c -> TambaraSum p a d # lmap :: (a -> b) -> TambaraSum p b c -> TambaraSum p a c # rmap :: (b -> c) -> TambaraSum p a b -> TambaraSum p a c # (#.) :: Coercible * c b => (b -> c) -> TambaraSum p a b -> TambaraSum p a c # (.#) :: Coercible * b a => TambaraSum p b c -> (a -> b) -> TambaraSum p a c #
Profunctor p => Choice (TambaraSum p) # |
Methods left' :: TambaraSum p a b -> TambaraSum p (Either a c) (Either b c) # right' :: TambaraSum p a b -> TambaraSum p (Either c a) (Either c b) #
Category * p => Category * (TambaraSum p) # |
Methods id :: cat a a # (.) :: cat b c -> cat a b -> cat a c #
Profunctor p => Functor (TambaraSum p a) # |
Methods fmap :: (a -> b) -> TambaraSum p a a -> TambaraSum p a b # (<$) :: a -> TambaraSum p a b -> TambaraSum p a a #

tambaraSum :: Choice p => (p :-> q) -> p :-> TambaraSum q #

    tambaraSum . untambaraSum ≡ id
    untambaraSum . tambaraSum ≡ id

untambaraSum :: Profunctor q => (p :-> TambaraSum q) -> p :-> q #

    tambaraSum . untambaraSum ≡ id
    untambaraSum . tambaraSum ≡ id

data PastroSum p a b where #

PastroSum -| TambaraSum

PastroSum freely constructs strength with respect to Either.

Constructors

PastroSum :: (Either y z -> b) -> p x y -> (a -> Either x z) -> PastroSum p a b |

Instances

ProfunctorMonad PastroSum # |
Methods proreturn :: Profunctor p => p :-> PastroSum p # projoin :: Profunctor p => PastroSum (PastroSum p) :-> PastroSum p #
ProfunctorFunctor PastroSum # |
Methods promap :: Profunctor p => (p :-> q) -> PastroSum p :-> PastroSum q #
ProfunctorAdjunction PastroSum TambaraSum # |
Methods unit :: Profunctor p => p :-> TambaraSum (PastroSum p) # counit :: Profunctor p => PastroSum (TambaraSum p) :-> p #
Profunctor (PastroSum p) # |
Methods dimap :: (a -> b) -> (c -> d) -> PastroSum p b c -> PastroSum p a d # lmap :: (a -> b) -> PastroSum p b c -> PastroSum p a c # rmap :: (b -> c) -> PastroSum p a b -> PastroSum p a c # (#.) :: Coercible * c b => (b -> c) -> PastroSum p a b -> PastroSum p a c # (.#) :: Coercible * b a => PastroSum p b c -> (a -> b) -> PastroSum p a c #
Choice (PastroSum p) # |
Methods left' :: PastroSum p a b -> PastroSum p (Either a c) (Either b c) # right' :: PastroSum p a b -> PastroSum p (Either c a) (Either c b) #

# Costrength

class Profunctor p => Cochoice p where #

Minimal complete definition

unleft | unright

Methods

unleft :: p (Either a d) (Either b d) -> p a b #

unright :: p (Either d a) (Either d b) -> p a b #

Instances

Cochoice (->) # |
Methods unleft :: (Either a d -> Either b d) -> a -> b # unright :: (Either d a -> Either d b) -> a -> b #
Applicative f => Cochoice (Costar f) # |
Methods unleft :: Costar f (Either a d) (Either b d) -> Costar f a b # unright :: Costar f (Either d a) (Either d b) -> Costar f a b #
Traversable f => Cochoice (Star f) # |
Methods unleft :: Star f (Either a d) (Either b d) -> Star f a b # unright :: Star f (Either d a) (Either d b) -> Star f a b #
Cochoice (CopastroSum p) # |
Methods unleft :: CopastroSum p (Either a d) (Either b d) -> CopastroSum p a b # unright :: CopastroSum p (Either d a) (Either d b) -> CopastroSum p a b #
Cochoice (CotambaraSum p) # |
Methods unleft :: CotambaraSum p (Either a d) (Either b d) -> CotambaraSum p a b # unright :: CotambaraSum p (Either d a) (Either d b) -> CotambaraSum p a b #
(Cochoice p, Cochoice q) => Cochoice (Product * * p q) # |
Methods unleft :: Product * * p q (Either a d) (Either b d) -> Product * * p q a b # unright :: Product * * p q (Either d a) (Either d b) -> Product * * p q a b #
(Functor f, Cochoice p) => Cochoice (Tannen * * * f p) # |
Methods unleft :: Tannen * * * f p (Either a d) (Either b d) -> Tannen * * * f p a b # unright :: Tannen * * * f p (Either d a) (Either d b) -> Tannen * * * f p a b #

data CotambaraSum q a b where #

`CotambaraSum` cofreely constructs costrength with respect to `Either` (aka `Choice`)

Constructors

CotambaraSum :: Cochoice r => (r :-> q) -> r a b -> CotambaraSum q a b |

Instances

ProfunctorComonad CotambaraSum # |
Methods proextract :: Profunctor p => CotambaraSum p :-> p # produplicate :: Profunctor p => CotambaraSum p :-> CotambaraSum (CotambaraSum p) #
ProfunctorFunctor CotambaraSum # |
Methods promap :: Profunctor p => (p :-> q) -> CotambaraSum p :-> CotambaraSum q #
ProfunctorAdjunction CopastroSum CotambaraSum # |
Methods unit :: Profunctor p => p :-> CotambaraSum (CopastroSum p) # counit :: Profunctor p => CopastroSum (CotambaraSum p) :-> p #
Profunctor (CotambaraSum p) # |
Methods dimap :: (a -> b) -> (c -> d) -> CotambaraSum p b c -> CotambaraSum p a d # lmap :: (a -> b) -> CotambaraSum p b c -> CotambaraSum p a c # rmap :: (b -> c) -> CotambaraSum p a b -> CotambaraSum p a c # (#.) :: Coercible * c b => (b -> c) -> CotambaraSum p a b -> CotambaraSum p a c # (.#) :: Coercible * b a => CotambaraSum p b c -> (a -> b) -> CotambaraSum p a c #
Cochoice (CotambaraSum p) # |
Methods unleft :: CotambaraSum p (Either a d) (Either b d) -> CotambaraSum p a b # unright :: CotambaraSum p (Either d a) (Either d b) -> CotambaraSum p a b #
Functor (CotambaraSum p a) # |
Methods fmap :: (a -> b) -> CotambaraSum p a a -> CotambaraSum p a b # (<$) :: a -> CotambaraSum p a b -> CotambaraSum p a a #

cotambaraSum :: Cochoice p => (p :-> q) -> p :-> CotambaraSum q #

    cotambaraSum . uncotambaraSum ≡ id
    uncotambaraSum . cotambaraSum ≡ id

uncotambaraSum :: Profunctor q => (p :-> CotambaraSum q) -> p :-> q #

    cotambaraSum . uncotambaraSum ≡ id
    uncotambaraSum . cotambaraSum ≡ id

newtype CopastroSum p a b #

CopastroSum -| CotambaraSum

`CopastroSum` freely constructs costrength with respect to `Either` (aka `Choice`)

Constructors

CopastroSum |
Fields runCopastroSum :: forall r. Cochoice r => (forall x y. p x y -> r x y) -> r a b

Instances

ProfunctorMonad CopastroSum # |
Methods proreturn :: Profunctor p => p :-> CopastroSum p # projoin :: Profunctor p => CopastroSum (CopastroSum p) :-> CopastroSum p #
ProfunctorFunctor CopastroSum # |
Methods promap :: Profunctor p => (p :-> q) -> CopastroSum p :-> CopastroSum q #
ProfunctorAdjunction CopastroSum CotambaraSum # |
Methods unit :: Profunctor p => p :-> CotambaraSum (CopastroSum p) # counit :: Profunctor p => CopastroSum (CotambaraSum p) :-> p #
Profunctor (CopastroSum p) # |
Methods dimap :: (a -> b) -> (c -> d) -> CopastroSum p b c -> CopastroSum p a d # lmap :: (a -> b) -> CopastroSum p b c -> CopastroSum p a c # rmap :: (b -> c) -> CopastroSum p a b -> CopastroSum p a c # (#.) :: Coercible * c b => (b -> c) -> CopastroSum p a b -> CopastroSum p a c # (.#) :: Coercible * b a => CopastroSum p b c -> (a -> b) -> CopastroSum p a c #
Cochoice (CopastroSum p) # |
Methods unleft :: CopastroSum p (Either a d) (Either b d) -> CopastroSum p a b # unright :: CopastroSum p (Either d a) (Either d b) -> CopastroSum p a b #