Safe Haskell | Safe |
---|---|
Language | Haskell98 |
- class BifunctorTrans t where
- bimapX :: (BifunctorTrans t, MMonad (t z), Monad (t y m), Monad m) => (x -> z) -> (y -> z) -> t x (t y m) a -> t z m a
- firstX :: (BifunctorTrans t, MMonad (t y), Functor (t y m), Monad m) => (x -> y) -> t x (t y m) a -> t y m a
- secondX :: (BifunctorTrans t, MMonad (t x), Monad (t y m), Monad m) => (y -> x) -> t x (t y m) a -> t x m a
Documentation
class BifunctorTrans t where Source #
Class of monad transformers which are bifunctors.
You can implement a BifunctorTrans
by either defining bimapT
or by
defining both firstT
and secondT
.
If you supply bimapT
, you should ensure that:
bimapT
id
id
≡id
If you supply first
and second
, ensure:
firstT
id
≡id
secondT
id
≡id
If you supply both, you should also ensure:
bimapT
f g ≡firstT
f.
secondT
g
These ensure by parametricity:
bimapT
(f.
g) (h.
i) ≡bimapT
f h.
bimapT
g ifirstT
(f.
g) ≡firstT
f.
firstT
gsecondT
(f.
g) ≡secondT
f.
secondT
g
bimapT :: Functor f => (x -> y) -> (a -> b) -> t x f a -> t y f b Source #
Map over both arguments at the same time.
bimap
f g ≡first
f.
second
g
firstT :: Functor f => (x -> y) -> t x f a -> t y f a Source #
secondT :: Functor f => (a -> b) -> t x f a -> t x f b Source #
Map covariantly over the second argument.
second
≡bimap
id
bimapX :: (BifunctorTrans t, MMonad (t z), Monad (t y m), Monad m) => (x -> z) -> (y -> z) -> t x (t y m) a -> t z m a Source #
Map over two stacked transformer bifunctors, unifying their type and squashing the result.