-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Composable monad transformers -- -- A version of monad transformers that (a) allows one to convince the -- type checker that transformer application is a monad, and (b) doesn't -- need lots of boilerplate to add a new transformer. It's supposed to -- play nicely with Control.Monad.Trans. -- -- In order to make a new transformer (say, T) an instance of -- TransM (TransP, TransF) class, all you have -- to do is: -- -- -- -- After that, you can use your new and shiny transformer in -- compositions, like ReaderT Char :. T :. WriterT String — and -- such a composition would automagically become a monad transmormer. @package compose-trans @version 0.0 -- | Basic definitions in the category (* -> *). module Control.Monad.Trans.Category -- | m :-> n is the set of morphisms (from m to -- n, naturally) in our category. type :-> m n = forall a. m a -> n a -- | If t is an endofunctor in our category, then t :$ m -- is basically the same as t m. newtype (:$) t m :: (* -> *) a ApplyF :: t m a -> :$ t a runApplyF :: :$ t a -> t m a -- | If t1 and t2 are endofunctorsm then t2 :. -- t1 is their composition (which is also an endofunctor) newtype (:.) t2 t1 m a ComposeF :: (t2 :$ (t1 :$ m)) a -> :. t2 t1 m a runComposeF :: :. t2 t1 m a -> (t2 :$ (t1 :$ m)) a -- | If m is an algebra over an endofunctor t, then it's -- structure morphism has the type Inst t m. type Inst c m = c m :-> m -- | Monad transformers. There are also MonadPlus and -- MonadFix transformes, see the corresponding modules. module Control.Monad.Trans.Monad -- | MonadM m is actually a free monad generated by m. -- MonadM is a monad itself (on the (* -> *) -- category), as usually happens with free structures. data MonadM m x -- | A composable monad transformer. -- -- You shoudn't (and probably can't) use *anything* except for -- instM, defined in this very module, as -- transMInst. -- -- If you define instance TransM T where transMInst = instM, -- then you would also need to define instance Monad m => Monad (T -- m) somewhere in your code. class (MonadTrans t) => TransM t transMInst :: (TransM t, Monad m) => Inst MonadM (t m) -- | A monad is nothing but an algebra over the MonadM monad. -- instM provides it's structure map. instM :: (Monad m) => Inst MonadM m -- | Sometimes we need an instance Monad T, while everything we've -- got is Inst MonadP T. In this case, return' serves -- as a return substitution. return' :: Inst MonadM m -> x -> m x -- | Sometimes we need an instance Monad T, while everything we've -- got is Inst MonadP T. In this case, bind' serves as -- a >>= substitution. bind' :: Inst MonadM m -> m x -> (x -> m y) -> m y instance (Monad m, TransM t1, TransM t2) => Monad ((:.) t2 t1 m) instance (MonadTrans t) => MonadTrans ((:$) t) instance (Monoid w) => TransM (WriterT w) instance TransM (StateT s) instance TransM (ReaderT r) instance TransM ListT instance TransM (ContT c) instance (TransM t1, TransM t2) => TransM (t2 :. t1) instance (TransM t1, MonadTrans t2) => MonadTrans (t2 :. t1) instance (Monad m, TransM t) => Monad (t :$ m) -- | MonadFix transformers. There are also Monad and -- MonadPlus transformes, see the corresponding modules. -- -- Note that each MonadFix transformer is also a Monad -- transformer. module Control.Monad.Trans.MonadFix -- | MonadF m is actually a free MonadFix generated by -- m. MonadF is a monad itself (on the (* -> -- *) category), as usually happens with free structures. data MonadF m x -- | A composable MonadFix transformer. -- -- You shoudn't (and probably can't) use *anything* except for -- instF, defined in this very module, as -- transFInst. -- -- If you define instance TransF T where transFInst = instF, -- then you would also need to define instance MonadFix m => -- MonadFix (T m) somewhere in your code. class (TransM t) => TransF t transFInst :: (TransF t, MonadFix m) => Inst MonadF (t m) -- | A MonadFix is nothing but an algebra over the MonadF -- monad. instF provides it's structure map. instF :: (MonadFix m) => Inst MonadF m -- | Sometimes we need an instance MonadFix T, while everything -- we've got is InstP MonadF T. In this case, mfix' -- serves as a mfix substitution. mfix' :: Inst MonadF m -> (x -> m x) -> m x instance (MonadFix m, TransF t1, TransF t2) => MonadFix ((:.) t2 t1 m) instance (Monoid w) => TransF (WriterT w) instance TransF (StateT s) instance TransF (ReaderT r) instance (TransF t1, TransF t2) => TransF (t2 :. t1) instance (MonadFix m, TransF t) => MonadFix (t :$ m) -- | MonadPlus transformers. There are also Monad and -- MonadFix transformes, see the corresponding modules. -- -- Note that each MonadPlus transformer is also a Monad -- transformer. module Control.Monad.Trans.MonadPlus -- | MonadP m is actually a free MonadPlus generated by -- m. MonadP is a monad itself (on the (* -> -- *) category), as usually happens with free structures. data MonadP m x -- | A composable MonadPlus transformer. -- -- You shoudn't (and probably can't) use *anything* except for -- instP, defined in this very module, as -- transPInst. -- -- If you define instance TransP T where transPInst = instP, -- then you would also need to define instance MonadPlus m => -- MonadPlus (T m) somewhere in your code. class (TransM t) => TransP t transPInst :: (TransP t, MonadPlus m) => Inst MonadP (t m) -- | A MonadPlus is nothing but an algebra over the -- MonadP monad. instP provides it's structure map. instP :: (MonadPlus m) => Inst MonadP m -- | Sometimes we need an instance MonadPlus T, while everything -- we've got is InstP MonadP T. In this case, mzero' -- serves as a mzero substitution. mzero' :: Inst MonadP m -> m x -- | Sometimes we need an instance Monad T, while everything we've -- got is Inst MonadP T. In this case, mplus' serves as -- a mplus substitution. mplus' :: Inst MonadP m -> m x -> m x -> m x instance (MonadPlus m, TransP t1, TransP t2) => MonadPlus ((:.) t2 t1 m) instance (Monoid w) => TransP (WriterT w) instance TransP (StateT s) instance TransP (ReaderT r) instance TransP ListT instance (TransP t1, TransP t2) => TransP (t2 :. t1) instance (MonadPlus m, TransP t) => MonadPlus (t :$ m)