Synopsis

# 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 i
firstT  (f . g) ≡ firstT  f . firstT  g
secondT (f . g) ≡ secondT f . secondT g


Minimal complete definition

Methods

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 #

Map covariantly over the first argument.

firstT f ≡ bimapT f id

secondT :: Functor f => (a -> b) -> t x f a -> t x f b Source #

Map covariantly over the second argument.

second ≡ bimap id

Instances

 Source # MethodsbimapT :: Functor f => (x -> y) -> (a -> b) -> ExceptT x f a -> ExceptT y f b Source #firstT :: Functor f => (x -> y) -> ExceptT x f a -> ExceptT y f a Source #secondT :: Functor f => (a -> b) -> ExceptT x f a -> ExceptT x f b Source # Source # MethodsbimapT :: Functor f => (x -> y) -> (a -> b) -> WriterT x f a -> WriterT y f b Source #firstT :: Functor f => (x -> y) -> WriterT x f a -> WriterT y f a Source #secondT :: Functor f => (a -> b) -> WriterT x f a -> WriterT x f b Source # Source # MethodsbimapT :: Functor f => (x -> y) -> (a -> b) -> WriterT x f a -> WriterT y f b Source #firstT :: Functor f => (x -> y) -> WriterT x f a -> WriterT y f a Source #secondT :: Functor f => (a -> b) -> WriterT x f a -> WriterT x f b Source #

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.

firstX :: (BifunctorTrans t, MMonad (t y), Functor (t y m), Monad m) => (x -> y) -> t x (t y m) a -> t y m a Source #

Map over the first of two stacked transformer bifunctors, unifying their type and squashing the result.

secondX :: (BifunctorTrans t, MMonad (t x), Monad (t y m), Monad m) => (y -> x) -> t x (t y m) a -> t x m a Source #

Map over the second of two stacked transformer bifunctors, unifying their type and squashing the result.