packages feed

compose-trans 0.0 → 0.1

raw patch · 4 files changed

+19/−20 lines, 4 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

- Control.Monad.Trans.Monad: instance (MonadTrans t) => MonadTrans ((:$) t)
- Control.Monad.Trans.Monad: instance (Monoid w) => TransM (WriterT w)
- Control.Monad.Trans.MonadFix: instance (Monoid w) => TransF (WriterT w)
- Control.Monad.Trans.MonadPlus: instance (Monoid w) => TransP (WriterT w)
+ Control.Monad.Trans.Monad: instance MonadTrans t => MonadTrans ((:$) t)
+ Control.Monad.Trans.Monad: instance Monoid w => TransM (WriterT w)
+ Control.Monad.Trans.MonadFix: instance Monoid w => TransF (WriterT w)
+ Control.Monad.Trans.MonadPlus: instance Monoid w => TransP (WriterT w)
- Control.Monad.Trans.Monad: class (MonadTrans t) => TransM t
+ Control.Monad.Trans.Monad: class MonadTrans t => TransM t
- Control.Monad.Trans.Monad: instM :: (Monad m) => Inst MonadM m
+ Control.Monad.Trans.Monad: instM :: Monad m => Inst MonadM m
- Control.Monad.Trans.MonadFix: class (TransM t) => TransF t
+ Control.Monad.Trans.MonadFix: class TransM t => TransF t
- Control.Monad.Trans.MonadFix: instF :: (MonadFix m) => Inst MonadF m
+ Control.Monad.Trans.MonadFix: instF :: MonadFix m => Inst MonadF m
- Control.Monad.Trans.MonadPlus: class (TransM t) => TransP t
+ Control.Monad.Trans.MonadPlus: class TransM t => TransP t
- Control.Monad.Trans.MonadPlus: instP :: (MonadPlus m) => Inst MonadP m
+ Control.Monad.Trans.MonadPlus: instP :: MonadPlus m => Inst MonadP m

Files

compose-trans.cabal view
@@ -10,18 +10,18 @@ 		. 		* define @instance Monad m => Monad (T m)@ &#x2014; also something quite common (for @TransP@ and @TransF@ you'd need another instance for @MonadPlus@ and @MonadFix@, respectively). 		.-		* write @instance Trans T where transMInst = instM@ &#x2014; which is exactly one line of boilerplate. Sorry for that.+		* write @instance Trans T where transMInst = instM@ &#x2014; which is exactly one line of boilerplate. Sorry about that. 		.-		After that, you can use your new and shiny transformer in compositions, like @ReaderT Char :. T :. WriterT String@ &#x2014; and such a composition would automagically become a monad transmormer.+		After that, you can use your new and shiny transformer in compositions, like @ReaderT Char :. T :. WriterT String@ &#x2014; and such a composition would automagically become a monad transformer. License:	BSD3 License-file:	LICENSE Maintainer:	miguelimo38@yandex.ru Name:		compose-trans Synopsis:	Composable monad transformers-Version:	0.0+Version:	0.1  Library-  Build-Depends:	base >= 2 && <= 4, mtl+  Build-Depends:	base >= 2 && < 5, mtl   Exposed-Modules:	Control.Monad.Trans.Category, Control.Monad.Trans.Monad, Control.Monad.Trans.MonadFix, Control.Monad.Trans.MonadPlus   Extensions:		GeneralizedNewtypeDeriving, RankNTypes, StandaloneDeriving, TypeOperators   GHC-Options:		-Wall -fno-warn-orphans
src/Control/Monad/Trans/Monad.hs view
@@ -20,11 +20,11 @@ bind' :: Inst MonadM m -> m x -> (x -> m y) -> m y bind' i mx f = i $ MonadM {bindM = \mor -> mor mx >>= mor . f} -- | 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 where transMInst :: Monad m => Inst MonadM (t m)+class MonadTrans t => TransM t where+  -- | 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.+  transMInst :: Monad m => Inst MonadM (t m) instance (Monad m, TransM t) => Monad (t :$ m) where     return x = ApplyF {runApplyF = return' transMInst x}     tmx >>= f = ApplyF {runApplyF = runApplyF tmx >>>= (runApplyF . f)} where (>>>=) = bind' transMInst
src/Control/Monad/Trans/MonadFix.hs view
@@ -9,7 +9,6 @@ import Control.Monad.Trans.Category import Control.Monad.Trans.Monad import Control.Monad.Writer-import Data.Monoid -- | @MonadF m@ is actually a free @MonadFix@ generated by @m@. @MonadF@ is a monad itself (on the @(* -> *)@ category), as usually happens with free structures. newtype MonadF m x = MonadF {bindF :: forall n. MonadFix n => (m :-> n) -> n x} -- | A @MonadFix@ is nothing but an algebra over the @MonadF@ monad. @instF@ provides it's structure map.@@ -19,11 +18,11 @@ mfix' :: Inst MonadF m -> (x -> m x) -> m x mfix' i f = i $ MonadF {bindF = \mor -> mfix $ mor . f} -- | 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 where transFInst :: MonadFix m => Inst MonadF (t m)+class TransM t => TransF t where+  -- | 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.+  transFInst :: MonadFix m => Inst MonadF (t m) instance (MonadFix m, TransF t) => MonadFix (t :$ m) where     mfix f = ApplyF {runApplyF = mfix' transFInst $ runApplyF . f} deriving instance (MonadFix m, TransF t1, TransF t2) => MonadFix ((t2 :. t1) m)
src/Control/Monad/Trans/MonadPlus.hs view
@@ -22,11 +22,11 @@ mplus' :: Inst MonadP m -> m x -> m x -> m x mplus' i mx1 mx2 = i $ MonadP {bindP = \mor -> mor mx1 `mplus` mor mx2} -- | 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 where transPInst :: MonadPlus m => Inst MonadP (t m)+class TransM t => TransP t where+  -- | 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.+  transPInst :: MonadPlus m => Inst MonadP (t m) instance (MonadPlus m, TransP t) => MonadPlus (t :$ m) where     mzero = ApplyF {runApplyF = mzero' transPInst}     tm1 `mplus` tm2 = ApplyF {runApplyF = runApplyF tm1 `mplus1` runApplyF tm2} where mplus1 = mplus' transPInst