profunctors-5.6.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 Safe
Language Haskell2010

Data.Profunctor.Choice

Description

Synopsis

Strength

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.

Minimal complete definition

left' | right'

Methods

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 Leftlmap 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 Rightlmap 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

Instances details
Monad m => Choice ( Kleisli m) Source #
Instance details

Defined in Data.Profunctor.Choice

Choice ( Tagged :: Type -> Type -> Type ) Source #
Instance details

Defined in Data.Profunctor.Choice

Choice p => Choice ( Tambara p) Source #
Instance details

Defined in Data.Profunctor.Choice

Choice ( PastroSum p) Source #
Instance details

Defined in Data.Profunctor.Choice

Profunctor p => Choice ( TambaraSum p) Source #
Instance details

Defined in Data.Profunctor.Choice

Choice ( FreeTraversing p) Source #
Instance details

Defined in Data.Profunctor.Traversing

Profunctor p => Choice ( CofreeTraversing p) Source #
Instance details

Defined in Data.Profunctor.Traversing

Choice ( FreeMapping p) Source #
Instance details

Defined in Data.Profunctor.Mapping

Profunctor p => Choice ( CofreeMapping p) Source #
Instance details

Defined in Data.Profunctor.Mapping

Choice p => Choice ( Coyoneda p) Source #
Instance details

Defined in Data.Profunctor.Yoneda

Choice p => Choice ( Yoneda p) Source #
Instance details

Defined in Data.Profunctor.Yoneda

Choice ((->) :: Type -> Type -> Type ) Source #
Instance details

Defined in Data.Profunctor.Choice

Methods

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

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

Comonad w => Choice ( Cokleisli w) Source #

extract approximates costrength

Instance details

Defined in Data.Profunctor.Choice

Monoid r => Choice ( Forget r :: Type -> Type -> Type ) Source #
Instance details

Defined in Data.Profunctor.Choice

Applicative f => Choice ( Star f) Source #
Instance details

Defined in Data.Profunctor.Choice

Functor f => Choice ( Joker f :: Type -> Type -> Type ) Source #
Instance details

Defined in Data.Profunctor.Choice

ArrowChoice p => Choice ( WrappedArrow p) Source #
Instance details

Defined in Data.Profunctor.Choice

( Choice p, Choice q) => Choice ( Sum p q) Source #
Instance details

Defined in Data.Profunctor.Choice

( Choice p, Choice q) => Choice ( Product p q) Source #
Instance details

Defined in Data.Profunctor.Choice

( Functor f, Choice p) => Choice ( Tannen f p) Source #
Instance details

Defined in Data.Profunctor.Choice

( Choice p, Choice q) => Choice ( Procompose p q) Source #
Instance details

Defined in Data.Profunctor.Composition

( Functor f, Choice p) => Choice ( Cayley f p) Source #
Instance details

Defined in Data.Profunctor.Cayley

newtype TambaraSum p a b Source #

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

Instances

Instances details
ProfunctorComonad TambaraSum Source #
Instance details

Defined in Data.Profunctor.Choice

ProfunctorAdjunction PastroSum TambaraSum Source #
Instance details

Defined in Data.Profunctor.Choice

Profunctor p => Profunctor ( TambaraSum p) Source #
Instance details

Defined in Data.Profunctor.Choice

Methods

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 p => Choice ( TambaraSum p) Source #
Instance details

Defined in Data.Profunctor.Choice

Category p => Category ( TambaraSum p :: Type -> Type -> Type ) Source #
Instance details

Defined in Data.Profunctor.Choice

Methods

id :: forall (a :: k). TambaraSum p a a Source #

(.) :: forall (b :: k) (c :: k) (a :: k). TambaraSum p b c -> TambaraSum p a b -> TambaraSum p a c Source #

ProfunctorFunctor TambaraSum Source #
Instance details

Defined in Data.Profunctor.Choice

Profunctor p => Functor ( TambaraSum p a) Source #
Instance details

Defined in Data.Profunctor.Choice

Methods

fmap :: (a0 -> b) -> TambaraSum p a a0 -> TambaraSum p a b Source #

(<$) :: a0 -> TambaraSum p a b -> TambaraSum p a a0 Source #

data PastroSum p a b where Source #

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

Instances details
ProfunctorMonad PastroSum Source #
Instance details

Defined in Data.Profunctor.Choice

ProfunctorAdjunction PastroSum TambaraSum Source #
Instance details

Defined in Data.Profunctor.Choice

Profunctor ( PastroSum p) Source #
Instance details

Defined in Data.Profunctor.Choice

Methods

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 #

Choice ( PastroSum p) Source #
Instance details

Defined in Data.Profunctor.Choice

ProfunctorFunctor PastroSum Source #
Instance details

Defined in Data.Profunctor.Choice

Functor ( PastroSum p a) Source #
Instance details

Defined in Data.Profunctor.Choice

Methods

fmap :: (a0 -> b) -> PastroSum p a a0 -> PastroSum p a b Source #

(<$) :: a0 -> PastroSum p a b -> PastroSum p a a0 Source #

Costrength

class Profunctor p => Cochoice p where Source #

Minimal complete definition

unleft | unright

Methods

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

Laws:

unleftunright . 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 . unleftunleft . 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:

unrightunleft . 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 . unrightunright . 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

Instances details
Cochoice ( CopastroSum p) Source #
Instance details

Defined in Data.Profunctor.Choice

Cochoice ( CotambaraSum p) Source #
Instance details

Defined in Data.Profunctor.Choice

Cochoice p => Cochoice ( Coyoneda p) Source #
Instance details

Defined in Data.Profunctor.Yoneda

Cochoice p => Cochoice ( Yoneda p) Source #
Instance details

Defined in Data.Profunctor.Yoneda

Cochoice ((->) :: Type -> Type -> Type ) Source #
Instance details

Defined in Data.Profunctor.Choice

Methods

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

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

Cochoice ( Forget r :: Type -> Type -> Type ) Source #
Instance details

Defined in Data.Profunctor.Choice

Applicative f => Cochoice ( Costar f) Source #
Instance details

Defined in Data.Profunctor.Choice

Traversable f => Cochoice ( Star f) Source #
Instance details

Defined in Data.Profunctor.Choice

( Cochoice p, Cochoice q) => Cochoice ( Sum p q) Source #
Instance details

Defined in Data.Profunctor.Choice

( Cochoice p, Cochoice q) => Cochoice ( Product p q) Source #
Instance details

Defined in Data.Profunctor.Choice

( Functor f, Cochoice p) => Cochoice ( Tannen f p) Source #
Instance details

Defined in Data.Profunctor.Choice

( Functor f, Cochoice p) => Cochoice ( Cayley f p) Source #
Instance details

Defined in Data.Profunctor.Cayley

data CotambaraSum q a b where Source #

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

Constructors

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

Instances

Instances details
ProfunctorComonad CotambaraSum Source #
Instance details

Defined in Data.Profunctor.Choice

ProfunctorAdjunction CopastroSum CotambaraSum Source #
Instance details

Defined in Data.Profunctor.Choice

Profunctor ( CotambaraSum p) Source #
Instance details

Defined in Data.Profunctor.Choice

Methods

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 #

Cochoice ( CotambaraSum p) Source #
Instance details

Defined in Data.Profunctor.Choice

ProfunctorFunctor CotambaraSum Source #
Instance details

Defined in Data.Profunctor.Choice

Functor ( CotambaraSum p a) Source #
Instance details

Defined in Data.Profunctor.Choice

newtype CopastroSum p a b Source #

CopastroSum -| CotambaraSum

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

Constructors

CopastroSum

Fields

Instances

Instances details
ProfunctorMonad CopastroSum Source #
Instance details

Defined in Data.Profunctor.Choice

ProfunctorAdjunction CopastroSum CotambaraSum Source #
Instance details

Defined in Data.Profunctor.Choice

Profunctor ( CopastroSum p) Source #
Instance details

Defined in Data.Profunctor.Choice

Methods

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 #

Cochoice ( CopastroSum p) Source #
Instance details

Defined in Data.Profunctor.Choice

ProfunctorFunctor CopastroSum Source #
Instance details

Defined in Data.Profunctor.Choice

Functor ( CopastroSum p a) Source #
Instance details

Defined in Data.Profunctor.Choice