profunctors-5.6.2: Profunctors
Copyright(C) 2014-2015 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityprovisional
PortabilityRank2Types
Safe HaskellSafe
LanguageHaskell2010

Data.Profunctor.Choice

Description

 
Synopsis

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) #

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) #

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) # 
Instance details

Defined in Data.Profunctor.Choice

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) #

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

Defined in Data.Profunctor.Choice

Methods

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

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

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

Defined in Data.Profunctor.Choice

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) # 
Instance details

Defined in Data.Profunctor.Choice

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) # 
Instance details

Defined in Data.Profunctor.Choice

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) # 
Instance details

Defined in Data.Profunctor.Traversing

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) # 
Instance details

Defined in Data.Profunctor.Traversing

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) # 
Instance details

Defined in Data.Profunctor.Mapping

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) # 
Instance details

Defined in Data.Profunctor.Mapping

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) #

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

Defined in Data.Profunctor.Yoneda

Methods

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

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

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

Defined in Data.Profunctor.Yoneda

Methods

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

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

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

Defined in Data.Profunctor.Choice

Methods

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

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

Comonad w => Choice (Cokleisli w) #

extract approximates costrength

Instance details

Defined in Data.Profunctor.Choice

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) #

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

Defined in Data.Profunctor.Choice

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) #

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

Defined in Data.Profunctor.Choice

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) #

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

Defined in Data.Profunctor.Choice

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) #

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

Defined in Data.Profunctor.Choice

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) #

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

Defined in Data.Profunctor.Choice

Methods

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

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

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

Defined in Data.Profunctor.Choice

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) # 
Instance details

Defined in Data.Profunctor.Choice

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) #

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

Defined in Data.Profunctor.Composition

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

Defined in Data.Profunctor.Cayley

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) #

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

Instances

Instances details
ProfunctorComonad TambaraSum # 
Instance details

Defined in Data.Profunctor.Choice

Methods

proextract :: forall (p :: Type -> Type -> Type). Profunctor p => TambaraSum p :-> p #

produplicate :: forall (p :: Type -> Type -> Type). Profunctor p => TambaraSum p :-> TambaraSum (TambaraSum p) #

ProfunctorAdjunction PastroSum TambaraSum # 
Instance details

Defined in Data.Profunctor.Choice

Methods

unit :: forall (p :: Type -> Type -> Type). Profunctor p => p :-> TambaraSum (PastroSum p) #

counit :: forall (p :: Type -> Type -> Type). Profunctor p => PastroSum (TambaraSum p) :-> p #

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

Defined in Data.Profunctor.Choice

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 #

(#.) :: forall a b c q. Coercible c b => q b c -> TambaraSum p a b -> TambaraSum p a c #

(.#) :: forall a b c q. Coercible b a => TambaraSum p b c -> q a b -> TambaraSum p a c #

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

Defined in Data.Profunctor.Choice

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 :: Type -> Type -> Type) # 
Instance details

Defined in Data.Profunctor.Choice

Methods

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

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

ProfunctorFunctor TambaraSum # 
Instance details

Defined in Data.Profunctor.Choice

Methods

promap :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). Profunctor p => (p :-> q) -> TambaraSum p :-> TambaraSum q #

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

Defined in Data.Profunctor.Choice

Methods

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

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

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

Instances details
ProfunctorMonad PastroSum # 
Instance details

Defined in Data.Profunctor.Choice

Methods

proreturn :: forall (p :: Type -> Type -> Type). Profunctor p => p :-> PastroSum p #

projoin :: forall (p :: Type -> Type -> Type). Profunctor p => PastroSum (PastroSum p) :-> PastroSum p #

ProfunctorAdjunction PastroSum TambaraSum # 
Instance details

Defined in Data.Profunctor.Choice

Methods

unit :: forall (p :: Type -> Type -> Type). Profunctor p => p :-> TambaraSum (PastroSum p) #

counit :: forall (p :: Type -> Type -> Type). Profunctor p => PastroSum (TambaraSum p) :-> p #

Profunctor (PastroSum p) # 
Instance details

Defined in Data.Profunctor.Choice

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 #

(#.) :: forall a b c q. Coercible c b => q b c -> PastroSum p a b -> PastroSum p a c #

(.#) :: forall a b c q. Coercible b a => PastroSum p b c -> q a b -> PastroSum p a c #

Choice (PastroSum p) # 
Instance details

Defined in Data.Profunctor.Choice

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) #

ProfunctorFunctor PastroSum # 
Instance details

Defined in Data.Profunctor.Choice

Methods

promap :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). Profunctor p => (p :-> q) -> PastroSum p :-> PastroSum q #

Functor (PastroSum p a) # 
Instance details

Defined in Data.Profunctor.Choice

Methods

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

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

Costrength

class Profunctor p => Cochoice p where #

Minimal complete definition

unleft | unright

Methods

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

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 #

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) # 
Instance details

Defined in Data.Profunctor.Choice

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) # 
Instance details

Defined in Data.Profunctor.Choice

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 (Coyoneda p) # 
Instance details

Defined in Data.Profunctor.Yoneda

Methods

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

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

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

Defined in Data.Profunctor.Yoneda

Methods

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

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

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

Defined in Data.Profunctor.Choice

Methods

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

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

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

Defined in Data.Profunctor.Choice

Methods

unleft :: Forget r (Either a d) (Either b d) -> Forget r a b #

unright :: Forget r (Either d a) (Either d b) -> Forget r a b #

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

Defined in Data.Profunctor.Choice

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) # 
Instance details

Defined in Data.Profunctor.Choice

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 p, Cochoice q) => Cochoice (Sum p q) # 
Instance details

Defined in Data.Profunctor.Choice

Methods

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

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

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

Defined in Data.Profunctor.Choice

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) # 
Instance details

Defined in Data.Profunctor.Choice

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 #

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

Defined in Data.Profunctor.Cayley

Methods

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

unright :: Cayley f p (Either d a) (Either d b) -> Cayley 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

Instances details
ProfunctorComonad CotambaraSum # 
Instance details

Defined in Data.Profunctor.Choice

Methods

proextract :: forall (p :: Type -> Type -> Type). Profunctor p => CotambaraSum p :-> p #

produplicate :: forall (p :: Type -> Type -> Type). Profunctor p => CotambaraSum p :-> CotambaraSum (CotambaraSum p) #

ProfunctorAdjunction CopastroSum CotambaraSum # 
Instance details

Defined in Data.Profunctor.Choice

Methods

unit :: forall (p :: Type -> Type -> Type). Profunctor p => p :-> CotambaraSum (CopastroSum p) #

counit :: forall (p :: Type -> Type -> Type). Profunctor p => CopastroSum (CotambaraSum p) :-> p #

Profunctor (CotambaraSum p) # 
Instance details

Defined in Data.Profunctor.Choice

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 #

(#.) :: forall a b c q. Coercible c b => q b c -> CotambaraSum p a b -> CotambaraSum p a c #

(.#) :: forall a b c q. Coercible b a => CotambaraSum p b c -> q a b -> CotambaraSum p a c #

Cochoice (CotambaraSum p) # 
Instance details

Defined in Data.Profunctor.Choice

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 #

ProfunctorFunctor CotambaraSum # 
Instance details

Defined in Data.Profunctor.Choice

Methods

promap :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). Profunctor p => (p :-> q) -> CotambaraSum p :-> CotambaraSum q #

Functor (CotambaraSum p a) # 
Instance details

Defined in Data.Profunctor.Choice

Methods

fmap :: (a0 -> b) -> CotambaraSum p a a0 -> CotambaraSum p a b #

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

newtype CopastroSum p a b #

CopastroSum -| CotambaraSum

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

Constructors

CopastroSum 

Fields

Instances

Instances details
ProfunctorMonad CopastroSum # 
Instance details

Defined in Data.Profunctor.Choice

Methods

proreturn :: forall (p :: Type -> Type -> Type). Profunctor p => p :-> CopastroSum p #

projoin :: forall (p :: Type -> Type -> Type). Profunctor p => CopastroSum (CopastroSum p) :-> CopastroSum p #

ProfunctorAdjunction CopastroSum CotambaraSum # 
Instance details

Defined in Data.Profunctor.Choice

Methods

unit :: forall (p :: Type -> Type -> Type). Profunctor p => p :-> CotambaraSum (CopastroSum p) #

counit :: forall (p :: Type -> Type -> Type). Profunctor p => CopastroSum (CotambaraSum p) :-> p #

Profunctor (CopastroSum p) # 
Instance details

Defined in Data.Profunctor.Choice

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 #

(#.) :: forall a b c q. Coercible c b => q b c -> CopastroSum p a b -> CopastroSum p a c #

(.#) :: forall a b c q. Coercible b a => CopastroSum p b c -> q a b -> CopastroSum p a c #

Cochoice (CopastroSum p) # 
Instance details

Defined in Data.Profunctor.Choice

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 #

ProfunctorFunctor CopastroSum # 
Instance details

Defined in Data.Profunctor.Choice

Methods

promap :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). Profunctor p => (p :-> q) -> CopastroSum p :-> CopastroSum q #

Functor (CopastroSum p a) # 
Instance details

Defined in Data.Profunctor.Choice

Methods

fmap :: (a0 -> b) -> CopastroSum p a a0 -> CopastroSum p a b #

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