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 |
Synopsis
- class Profunctor p => Choice (p :: Type -> Type -> Type) where
- newtype TambaraSum (p :: Type -> Type -> Type) a b = TambaraSum {
- runTambaraSum :: forall c. p (Either a c) (Either b c)
- tambaraSum :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). Choice p => (p :-> q) -> p :-> TambaraSum q
- untambaraSum :: forall (q :: Type -> Type -> Type) (p :: Type -> Type -> Type). Profunctor q => (p :-> TambaraSum q) -> p :-> q
- data PastroSum (p :: Type -> Type -> Type) a b where
- class Profunctor p => Cochoice (p :: Type -> Type -> Type) where
- data CotambaraSum (q :: Type -> Type -> Type) a b where
- CotambaraSum :: forall (r :: Type -> Type -> Type) (q :: Type -> Type -> Type) a b. Cochoice r => (r :-> q) -> r a b -> CotambaraSum q a b
- cotambaraSum :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). Cochoice p => (p :-> q) -> p :-> CotambaraSum q
- uncotambaraSum :: forall (q :: Type -> Type -> Type) (p :: Type -> Type -> Type). Profunctor q => (p :-> CotambaraSum q) -> p :-> q
- newtype CopastroSum (p :: Type -> Type -> Type) a b = CopastroSum {
- runCopastroSum :: forall (r :: Type -> Type -> Type). Cochoice r => (forall x y. p x y -> r x y) -> r a b
Strength
class Profunctor p => Choice (p :: Type -> Type -> Type) 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
newtype TambaraSum (p :: Type -> Type -> Type) 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.
TambaraSum | |
|
Instances
tambaraSum :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). Choice p => (p :-> q) -> p :-> TambaraSum q Source #
untambaraSum :: forall (q :: Type -> Type -> Type) (p :: Type -> Type -> Type). Profunctor q => (p :-> TambaraSum q) -> p :-> q Source #
data PastroSum (p :: Type -> Type -> Type) a b where Source #
PastroSum -| TambaraSum
PastroSum freely constructs strength with respect to Either.
PastroSum :: forall y z b (p :: Type -> Type -> Type) x a. (Either y z -> b) -> p x y -> (a -> Either x z) -> PastroSum p a b |
Instances
ProfunctorMonad PastroSum Source # | |
ProfunctorAdjunction PastroSum TambaraSum Source # | |
Defined in Data.Profunctor.Choice unit :: forall (p :: Type -> Type -> Type). Profunctor p => p :-> TambaraSum (PastroSum p) Source # counit :: forall (p :: Type -> Type -> Type). Profunctor p => PastroSum (TambaraSum p) :-> p Source # | |
ProfunctorFunctor PastroSum Source # | |
Choice (PastroSum p) 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 # | |
Functor (PastroSum p a) Source # | |
Costrength
class Profunctor p => Cochoice (p :: Type -> Type -> Type) 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 # | |
Applicative f => Cochoice (Costar f) Source # | |
Cochoice (Forget r :: Type -> Type -> Type) Source # | |
Traversable f => Cochoice (Star f) Source # | |
Cochoice (->) Source # | |
(Cochoice p, Cochoice q) => Cochoice (Product p q) Source # | |
(Cochoice p, Cochoice q) => Cochoice (Sum p q) Source # | |
(Functor f, Cochoice p) => Cochoice (Tannen f p) Source # | |
(Functor f, Cochoice p) => Cochoice (Cayley f p) Source # | |
data CotambaraSum (q :: Type -> Type -> Type) a b where Source #
CotambaraSum
cofreely constructs costrength with respect to Either
(aka Choice
)
CotambaraSum :: forall (r :: Type -> Type -> Type) (q :: Type -> Type -> Type) a b. Cochoice r => (r :-> q) -> r a b -> CotambaraSum q a b |
Instances
cotambaraSum :: forall (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). Cochoice p => (p :-> q) -> p :-> CotambaraSum q Source #
uncotambaraSum :: forall (q :: Type -> Type -> Type) (p :: Type -> Type -> Type). Profunctor q => (p :-> CotambaraSum q) -> p :-> q Source #
newtype CopastroSum (p :: Type -> Type -> Type) a b Source #
CopastroSum -| CotambaraSum
CopastroSum
freely constructs costrength with respect to Either
(aka Choice
)
CopastroSum | |
|