contstuff-monads-tf 0.1.0 → 0.2.0
raw patch · 2 files changed
+91/−45 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Control.ContStuff.MonadsTf: instance (Applicative m, MonadError m) => HasExceptions m
- Control.ContStuff.MonadsTf: instance Applicative m => Abortable (ContT r m)
- Control.ContStuff.MonadsTf: instance MonadCont m => CallCC m
- Control.ContStuff.MonadsTf: instance MonadIO m => LiftBase m
- Control.ContStuff.MonadsTf: instance MonadState m => Stateful m
- Control.ContStuff.MonadsTf: instance MonadTrans t => Transformer t
+ Control.ContStuff.MonadsTf: class Monad m => MonadIO m :: (* -> *)
+ Control.ContStuff.MonadsTf: class MonadTrans t :: ((* -> *) -> * -> *)
+ Control.ContStuff.MonadsTf: instance (Error e, LiftBase m, Monad m) => LiftBase (ErrorT e m)
+ Control.ContStuff.MonadsTf: instance (LiftBase m, Monad m) => LiftBase (ContT r m)
+ Control.ContStuff.MonadsTf: instance (LiftBase m, Monad m) => LiftBase (ListT m)
+ Control.ContStuff.MonadsTf: instance (LiftBase m, Monad m) => LiftBase (ReaderT r m)
+ Control.ContStuff.MonadsTf: instance (LiftBase m, Monad m) => LiftBase (StateT s m)
+ Control.ContStuff.MonadsTf: instance (LiftBase m, Monad m, Monoid w) => LiftBase (RWST r w s m)
+ Control.ContStuff.MonadsTf: instance (LiftBase m, Monad m, Monoid w) => LiftBase (WriterT w m)
+ Control.ContStuff.MonadsTf: instance Error e => Transformer (ErrorT e)
+ Control.ContStuff.MonadsTf: instance MonadIO m => MonadIO (ChoiceT r i m)
+ Control.ContStuff.MonadsTf: instance MonadIO m => MonadIO (ContT r m)
+ Control.ContStuff.MonadsTf: instance MonadIO m => MonadIO (EitherT r e m)
+ Control.ContStuff.MonadsTf: instance MonadIO m => MonadIO (MaybeT r m)
+ Control.ContStuff.MonadsTf: instance MonadIO m => MonadIO (StateT r s m)
+ Control.ContStuff.MonadsTf: instance MonadTrans (ChoiceT r i)
+ Control.ContStuff.MonadsTf: instance MonadTrans (ContT r)
+ Control.ContStuff.MonadsTf: instance MonadTrans (EitherT r e)
+ Control.ContStuff.MonadsTf: instance MonadTrans (MaybeT r)
+ Control.ContStuff.MonadsTf: instance MonadTrans (StateT r s)
+ Control.ContStuff.MonadsTf: instance Monoid w => Transformer (RWST r w s)
+ Control.ContStuff.MonadsTf: instance Monoid w => Transformer (WriterT w)
+ Control.ContStuff.MonadsTf: instance Transformer (ContT r)
+ Control.ContStuff.MonadsTf: instance Transformer (ReaderT r)
+ Control.ContStuff.MonadsTf: instance Transformer (StateT s)
+ Control.ContStuff.MonadsTf: instance Transformer ListT
+ Control.ContStuff.MonadsTf: liftIO :: MonadIO m => IO a -> m a
+ Control.ContStuff.MonadsTf: liftTF :: (Monad m, MonadTrans t) => m a -> t m a
Files
- Control/ContStuff/MonadsTf.hs +83/−38
- contstuff-monads-tf.cabal +8/−7
Control/ContStuff/MonadsTf.hs view
@@ -5,55 +5,100 @@ -- Maintainer: Ertugrul Soeylemez <es@ertes.de> -- Stability: experimental ----- This module provides contstuff class instances for the monads from--- the monads-tf package. This makes using both transformer libraries--- in a single project much more convenient.+-- This package provides contstuff transformer class instances for the+-- monad transformers from the monads-tf package as well as monads-tf+-- transformer class instances for the monad transformers from+-- contstuff. This makes using both transformer libraries in a single+-- project much more convenient as you get along with a single set of+-- lifting functions. -{-# LANGUAGE- FlexibleInstances,- TypeFamilies,- UndecidableInstances- #-}+{-# LANGUAGE TypeFamilies #-} -module Control.ContStuff.MonadsTf () where+module Control.ContStuff.MonadsTf+ ( -- * Exported from monads-tf+ MonadIO(..),+ MonadTrans,+ liftTF+ )+ where import qualified Control.Monad.Trans as T-import Control.Applicative-import Control.ContStuff.Classes-import Control.Monad.Cont as Cont (MonadCont(..), ContT(..))-import Control.Monad.Error (MonadError(..))-import Control.Monad.State.Class as State (MonadState(..))+import qualified Control.ContStuff.Trans as C+import Control.ContStuff.Classes as C+import Control.Monad.Trans (MonadIO, MonadTrans, liftIO)+import Data.Monoid +import qualified Control.Monad.Cont as T (ContT)+import qualified Control.Monad.Error as T (Error, ErrorT)+import qualified Control.Monad.List as T (ListT)+import qualified Control.Monad.RWS.Lazy as T (RWST)+import qualified Control.Monad.RWS.Strict as TS (RWST)+import qualified Control.Monad.Reader as T (ReaderT)+import qualified Control.Monad.State.Lazy as T (StateT)+import qualified Control.Monad.State.Strict as TS (StateT)+import qualified Control.Monad.Writer.Lazy as T (WriterT)+import qualified Control.Monad.Writer.Strict as TS (WriterT) --- ================= ----- Generic instances ----- ================= -- -instance MonadCont m => CallCC m where- callCC = Cont.callCC+-- ====================== --+-- Interface to monads-tf --+-- ====================== -- -instance (Applicative m, MonadError m) => HasExceptions m where- type Exception m = ErrorType m- raise = throwError- try = flip catchError (pure . Left) . fmap Right+-- | Interface to 'Control.Monad.Trans.lift'. -instance T.MonadIO m => LiftBase m where- type Base m = IO- base = T.liftIO+liftTF :: (Monad m, MonadTrans t) => m a -> t m a+liftTF = T.lift -instance MonadState m => Stateful m where- type StateOf m = StateType m- get = State.get- putLazy = State.put -instance T.MonadTrans t => Transformer t where- lift = T.lift+-- ============================================== --+-- monads-tf instances for ContStuff transformers --+-- ============================================== -- +instance MonadTrans (C.ChoiceT r i) where lift = C.lift+instance MonadTrans (C.ContT r) where lift = C.lift+instance MonadTrans (C.EitherT r e) where lift = C.lift+instance MonadTrans (C.MaybeT r) where lift = C.lift+instance MonadTrans (C.StateT r s) where lift = C.lift --- ================== ----- Specific instances ----- ================== --+instance MonadIO m => MonadIO (C.ChoiceT r i m) where liftIO = liftTF . liftIO+instance MonadIO m => MonadIO (C.ContT r m) where liftIO = liftTF . liftIO+instance MonadIO m => MonadIO (C.EitherT r e m) where liftIO = liftTF . liftIO+instance MonadIO m => MonadIO (C.MaybeT r m) where liftIO = liftTF . liftIO+instance MonadIO m => MonadIO (C.StateT r s m) where liftIO = liftTF . liftIO -instance Applicative m => Abortable (ContT r m) where- type Result (ContT r m) = r- abort = ContT . const . pure++-- ============================================== --+-- ContStuff instances for monads-tf transformers --+-- ============================================== --++instance Transformer (T.ContT r) where lift = liftTF+instance T.Error e => Transformer (T.ErrorT e) where lift = liftTF+instance Transformer (T.ListT) where lift = liftTF+instance Monoid w => Transformer (T.RWST r w s) where lift = liftTF+instance Monoid w => Transformer (TS.RWST r w s) where lift = liftTF+instance Transformer (T.ReaderT r) where lift = liftTF+instance Transformer (T.StateT s) where lift = liftTF+instance Transformer (TS.StateT s) where lift = liftTF+instance Monoid w => Transformer (T.WriterT w) where lift = liftTF+instance Monoid w => Transformer (TS.WriterT w) where lift = liftTF++instance (LiftBase m, Monad m) => LiftBase (T.ContT r m) where+ type Base (T.ContT r m) = Base m; base = lift . base+instance (T.Error e, LiftBase m, Monad m) => LiftBase (T.ErrorT e m) where+ type Base (T.ErrorT e m) = Base m; base = lift . base+instance (LiftBase m, Monad m) => LiftBase (T.ListT m) where+ type Base (T.ListT m) = Base m; base = lift . base+instance (LiftBase m, Monad m, Monoid w) => LiftBase (T.RWST r w s m) where+ type Base (T.RWST r w s m) = Base m; base = lift . base+instance (LiftBase m, Monad m, Monoid w) => LiftBase (TS.RWST r w s m) where+ type Base (TS.RWST r w s m) = Base m; base = lift . base+instance (LiftBase m, Monad m) => LiftBase (T.ReaderT r m) where+ type Base (T.ReaderT r m) = Base m; base = lift . base+instance (LiftBase m, Monad m) => LiftBase (T.StateT s m) where+ type Base (T.StateT s m) = Base m; base = lift . base+instance (LiftBase m, Monad m) => LiftBase (TS.StateT s m) where+ type Base (TS.StateT s m) = Base m; base = lift . base+instance (LiftBase m, Monad m, Monoid w) => LiftBase (T.WriterT w m) where+ type Base (T.WriterT w m) = Base m; base = lift . base+instance (LiftBase m, Monad m, Monoid w) => LiftBase (TS.WriterT w m) where+ type Base (TS.WriterT w m) = Base m; base = lift . base
contstuff-monads-tf.cabal view
@@ -1,5 +1,5 @@ Name: contstuff-monads-tf-Version: 0.1.0+Version: 0.2.0 Category: Control, Monads Synopsis: ContStuff instances for monads-tf transformers Maintainer: Ertugrul Söylemez <es@ertes.de>@@ -12,19 +12,20 @@ Cabal-version: >= 1.6 Description: - This package provides contstuff class instances for the monads from- the monads-tf package. This makes using both transformer libraries- in a single project much more convenient.+ This package provides contstuff transformer class instances for the+ monad transformers from the monads-tf package as well as monads-tf+ transformer class instances for the monad transformers from+ contstuff. This makes using both transformer libraries in a single+ project much more convenient as you get along with a single set of+ lifting functions. Library Build-depends: base >= 4 && <= 5, contstuff >= 0.7.0, monads-tf >= 0.1.0- GHC-Options: -W+ GHC-Options: -W Extensions:- FlexibleInstances TypeFamilies- UndecidableInstances Exposed-modules: Control.ContStuff.MonadsTf