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
Contents
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
- 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.
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
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) #
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
Monad m => Choice (Kleisli m) # | |
Defined in Data.Profunctor.Choice | |
Choice (PastroSum p) # | |
Profunctor p => Choice (TambaraSum p) # | |
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) # | |
Profunctor p => Choice (CofreeMapping p) # | |
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 (FreeMapping p) # | |
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) # | |
Choice p => Choice (Tambara p) # | |
Profunctor p => Choice (CofreeTraversing p) # | |
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 (FreeTraversing p) # | |
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) # | |
Choice p => Choice (Coyoneda p) # | |
Choice p => Choice (Yoneda p) # | |
Choice (Tagged :: Type -> Type -> Type) # | |
Comonad w => Choice (Cokleisli w) # |
|
Monoid r => Choice (Forget r :: Type -> Type -> Type) # | |
Applicative f => Choice (Star f) # | |
Choice (->) # | |
Defined in Data.Profunctor.Choice | |
Functor f => Choice (Joker f :: Type -> Type -> Type) # | |
ArrowChoice p => Choice (WrappedArrow p) # | |
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 (Product p q) # | |
(Choice p, Choice q) => Choice (Sum p q) # | |
(Functor f, Choice p) => Choice (Tannen f p) # | |
(Functor f, Choice p) => Choice (Cayley f p) # | |
(Choice p, Choice q) => Choice (Procompose p q) # | |
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) # |
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
ProfunctorComonad TambaraSum # | |
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 # | |
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 # | |
ProfunctorFunctor TambaraSum # | |
Defined in Data.Profunctor.Choice Methods promap :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). Profunctor p => (p :-> q) -> TambaraSum p :-> TambaraSum q # | |
Category p => Category (TambaraSum p :: Type -> Type -> Type) # | |
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 | |
Profunctor p => Choice (TambaraSum p) # | |
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) # | |
Profunctor p => Profunctor (TambaraSum p) # | |
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 => Functor (TambaraSum p a) # | |
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 # |
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
PastroSum -| TambaraSum
PastroSum freely constructs strength with respect to Either.
Instances
ProfunctorMonad PastroSum # | |
Defined in Data.Profunctor.Choice | |
ProfunctorAdjunction PastroSum TambaraSum # | |
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 # | |
ProfunctorFunctor PastroSum # | |
Defined in Data.Profunctor.Choice | |
Choice (PastroSum p) # | |
Profunctor (PastroSum p) # | |
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 # | |
Functor (PastroSum p a) # | |
Costrength
class Profunctor p => Cochoice p where #
Methods
unleft :: p (Either a d) (Either b d) -> p a b #
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 #
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) # | |
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) # | |
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) # | |
Cochoice p => Cochoice (Yoneda p) # | |
Applicative f => Cochoice (Costar f) # | |
Cochoice (Forget r :: Type -> Type -> Type) # | |
Traversable f => Cochoice (Star f) # | |
Cochoice (->) # | |
Defined in Data.Profunctor.Choice | |
(Cochoice p, Cochoice q) => Cochoice (Product p q) # | |
(Cochoice p, Cochoice q) => Cochoice (Sum p q) # | |
(Functor f, Cochoice p) => Cochoice (Tannen f p) # | |
(Functor f, Cochoice p) => Cochoice (Cayley f p) # | |
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 # | |
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 # | |
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 # | |
ProfunctorFunctor CotambaraSum # | |
Defined in Data.Profunctor.Choice Methods promap :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). Profunctor p => (p :-> q) -> CotambaraSum p :-> CotambaraSum q # | |
Cochoice (CotambaraSum p) # | |
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 # | |
Profunctor (CotambaraSum p) # | |
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 # | |
Functor (CotambaraSum p a) # | |
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 # |
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
|
Instances
ProfunctorMonad CopastroSum # | |
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 # | |
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 # | |
ProfunctorFunctor CopastroSum # | |
Defined in Data.Profunctor.Choice Methods promap :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). Profunctor p => (p :-> q) -> CopastroSum p :-> CopastroSum q # | |
Cochoice (CopastroSum p) # | |
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 # | |
Profunctor (CopastroSum p) # | |
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 # | |
Functor (CopastroSum p a) # | |
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 # |