packages feed

monads-fd 0.0.0.1 → 0.2.0.0

raw patch · 22 files changed

Files

Control/Monad/Cont.hs view
@@ -3,11 +3,11 @@ Copyright   :  (c) The University of Glasgow 2001,                (c) Jeff Newbern 2003-2007,                (c) Andriy Palamarchuk 2007-License     :  BSD-style (see the file libraries/base/LICENSE)+License     :  BSD-style (see the file LICENSE) -Maintainer  :  libraries@haskell.org+Maintainer  :  ross@soi.city.ac.uk Stability   :  experimental-Portability :  non-portable (multi-parameter type classes)+Portability :  portable  [Computation type:] Computations which can be interrupted and resumed. 
Control/Monad/Cont/Class.hs view
@@ -3,11 +3,11 @@ Copyright   :  (c) The University of Glasgow 2001,                (c) Jeff Newbern 2003-2007,                (c) Andriy Palamarchuk 2007-License     :  BSD-style (see the file libraries/base/LICENSE)+License     :  BSD-style (see the file LICENSE) -Maintainer  :  libraries@haskell.org+Maintainer  :  ross@soi.city.ac.uk Stability   :  experimental-Portability :  non-portable (multi-parameter type classes)+Portability :  portable  [Computation type:] Computations which can be interrupted and resumed. @@ -52,79 +52,4 @@     MonadCont(..),   ) where -import Control.Monad.Trans.Cont (ContT)-import qualified Control.Monad.Trans.Cont as ContT-import Control.Monad.Trans.Error as Error-import Control.Monad.Trans.Identity as Identity-import Control.Monad.Trans.List as List-import Control.Monad.Trans.Maybe as Maybe-import Control.Monad.Trans.Reader as Reader-import Control.Monad.Trans.RWS.Lazy as LazyRWS-import Control.Monad.Trans.RWS.Strict as StrictRWS-import Control.Monad.Trans.State.Lazy as LazyState-import Control.Monad.Trans.State.Strict as StrictState-import Control.Monad.Trans.Writer.Lazy as LazyWriter-import Control.Monad.Trans.Writer.Strict as StrictWriter--import Control.Monad-import Data.Monoid--class (Monad m) => MonadCont m where-    {- | @callCC@ (call-with-current-continuation)-    calls a function with the current continuation as its argument.-    Provides an escape continuation mechanism for use with Continuation monads.-    Escape continuations allow to abort the current computation and return-    a value immediately.-    They achieve a similar effect to 'Control.Monad.Error.throwError'-    and 'Control.Monad.Error.catchError'-    within an 'Control.Monad.Error.Error' monad.-    Advantage of this function over calling @return@ is that it makes-    the continuation explicit,-    allowing more flexibility and better control-    (see examples in "Control.Monad.Cont").--    The standard idiom used with @callCC@ is to provide a lambda-expression-    to name the continuation. Then calling the named continuation anywhere-    within its scope will escape from the computation,-    even if it is many layers deep within nested computations.-    -}-    callCC :: ((a -> m b) -> m a) -> m a--instance (Monad m) => MonadCont (ContT r m) where-    callCC = ContT.callCC---- ------------------------------------------------------------------------------ Instances for other mtl transformers--instance (Error e, MonadCont m) => MonadCont (ErrorT e m) where-    callCC = Error.liftCallCC callCC--instance (MonadCont m) => MonadCont (IdentityT m) where-    callCC = Identity.liftCallCC callCC--instance (MonadCont m) => MonadCont (ListT m) where-    callCC = List.liftCallCC callCC--instance (MonadCont m) => MonadCont (MaybeT m) where-    callCC = Maybe.liftCallCC callCC--instance (MonadCont m) => MonadCont (ReaderT r m) where-    callCC = Reader.liftCallCC callCC--instance (Monoid w, MonadCont m) => MonadCont (LazyRWS.RWST r w s m) where-    callCC = LazyRWS.liftCallCC' callCC--instance (Monoid w, MonadCont m) => MonadCont (StrictRWS.RWST r w s m) where-    callCC = StrictRWS.liftCallCC' callCC--instance (MonadCont m) => MonadCont (LazyState.StateT s m) where-    callCC = LazyState.liftCallCC' callCC--instance (MonadCont m) => MonadCont (StrictState.StateT s m) where-    callCC = StrictState.liftCallCC' callCC--instance (Monoid w, MonadCont m) => MonadCont (LazyWriter.WriterT w m) where-    callCC = LazyWriter.liftCallCC callCC--instance (Monoid w, MonadCont m) => MonadCont (StrictWriter.WriterT w m) where-    callCC = StrictWriter.liftCallCC callCC+import "mtl" Control.Monad.Cont.Class
Control/Monad/Error.hs view
@@ -3,9 +3,9 @@ Copyright   :  (c) Michael Weber <michael.weber@post.rwth-aachen.de> 2001,                (c) Jeff Newbern 2003-2006,                (c) Andriy Palamarchuk 2006-License     :  BSD-style (see the file libraries/base/LICENSE)+License     :  BSD-style (see the file LICENSE) -Maintainer  :  libraries@haskell.org+Maintainer  :  ross@soi.city.ac.uk Stability   :  experimental Portability :  non-portable (multi-parameter type classes) @@ -34,7 +34,7 @@ module Control.Monad.Error (     -- * Monads with error handling     MonadError(..),-    Error,+    Error(..),     -- * The ErrorT monad transformer     ErrorT(..),     mapErrorT,
Control/Monad/Error/Class.hs view
@@ -1,13 +1,11 @@-{-# LANGUAGE UndecidableInstances #-}- {- | Module      :  Control.Monad.Error.Class Copyright   :  (c) Michael Weber <michael.weber@post.rwth-aachen.de> 2001,                (c) Jeff Newbern 2003-2006,                (c) Andriy Palamarchuk 2006-License     :  BSD-style (see the file libraries/base/LICENSE)+License     :  BSD-style (see the file LICENSE) -Maintainer  :  libraries@haskell.org+Maintainer  :  ross@soi.city.ac.uk Stability   :  experimental Portability :  non-portable (multi-parameter type classes) @@ -38,111 +36,4 @@     MonadError(..),   ) where -import Control.Monad.Trans.Error (Error(..), ErrorT)-import qualified Control.Monad.Trans.Error as ErrorT (throwError, catchError)-import Control.Monad.Trans.Identity as Identity-import Control.Monad.Trans.List as List-import Control.Monad.Trans.Maybe as Maybe-import Control.Monad.Trans.Reader as Reader-import Control.Monad.Trans.RWS.Lazy as LazyRWS-import Control.Monad.Trans.RWS.Strict as StrictRWS-import Control.Monad.Trans.State.Lazy as LazyState-import Control.Monad.Trans.State.Strict as StrictState-import Control.Monad.Trans.Writer.Lazy as LazyWriter-import Control.Monad.Trans.Writer.Strict as StrictWriter-import Control.Monad.Trans--import Control.Monad-import Control.Monad.Instances ()-import Data.Monoid-import System.IO--{- |-The strategy of combining computations that can throw exceptions-by bypassing bound functions-from the point an exception is thrown to the point that it is handled.--Is parameterized over the type of error information and-the monad type constructor.-It is common to use @'Data.Either' String@ as the monad type constructor-for an error monad in which error descriptions take the form of strings.-In that case and many other common cases the resulting monad is already defined-as an instance of the 'MonadError' class.-You can also define your own error type and\/or use a monad type constructor-other than @'Data.Either' String@ or @'Data.Either' IOError@.-In these cases you will have to explicitly define instances of the 'Error'-and\/or 'MonadError' classes.--}-class (Monad m) => MonadError e m | m -> e where-    -- | Is used within a monadic computation to begin exception processing.-    throwError :: e -> m a--    {- |-    A handler function to handle previous errors and return to normal execution.-    A common idiom is:--    > do { action1; action2; action3 } `catchError` handler--    where the @action@ functions can call 'throwError'.-    Note that @handler@ and the do-block must have the same return type.-    -}-    catchError :: m a -> (e -> m a) -> m a--instance MonadError IOError IO where-    throwError = ioError-    catchError = catch---- ------------------------------------------------------------------------------ Our parameterizable error monad--instance (Error e) => MonadError e (Either e) where-    throwError             = Left-    Left  l `catchError` h = h l-    Right r `catchError` _ = Right r--instance (Monad m, Error e) => MonadError e (ErrorT e m) where-    throwError = ErrorT.throwError-    catchError = ErrorT.catchError---- ------------------------------------------------------------------------------ Instances for other mtl transformers--instance (MonadError e m) => MonadError e (IdentityT m) where-    throwError = lift . throwError-    catchError = Identity.liftCatch catchError--instance (MonadError e m) => MonadError e (ListT m) where-    throwError = lift . throwError-    catchError = List.liftCatch catchError--instance (MonadError e m) => MonadError e (MaybeT m) where-    throwError = lift . throwError-    catchError = Maybe.liftCatch catchError--instance (MonadError e m) => MonadError e (ReaderT r m) where-    throwError = lift . throwError-    catchError = Reader.liftCatch catchError--instance (Monoid w, MonadError e m) => MonadError e (LazyRWS.RWST r w s m) where-    throwError = lift . throwError-    catchError = LazyRWS.liftCatch catchError--instance (Monoid w, MonadError e m) => MonadError e (StrictRWS.RWST r w s m) where-    throwError = lift . throwError-    catchError = StrictRWS.liftCatch catchError--instance (MonadError e m) => MonadError e (LazyState.StateT s m) where-    throwError = lift . throwError-    catchError = LazyState.liftCatch catchError--instance (MonadError e m) => MonadError e (StrictState.StateT s m) where-    throwError = lift . throwError-    catchError = StrictState.liftCatch catchError--instance (Monoid w, MonadError e m) => MonadError e (LazyWriter.WriterT w m) where-    throwError = lift . throwError-    catchError = LazyWriter.liftCatch catchError--instance (Monoid w, MonadError e m) => MonadError e (StrictWriter.WriterT w m) where-    throwError = lift . throwError-    catchError = StrictWriter.liftCatch catchError+import "mtl" Control.Monad.Error.Class
+ Control/Monad/Identity.hs view
@@ -0,0 +1,44 @@+{- |+Module      :  Control.Monad.Identity+Copyright   :  (c) Andy Gill 2001,+               (c) Oregon Graduate Institute of Science and Technology 2001,+               (c) Jeff Newbern 2003-2006,+               (c) Andriy Palamarchuk 2006+License     :  BSD-style (see the file LICENSE)++Maintainer  :  ross@soi.city.ac.uk+Stability   :  experimental+Portability :  portable++[Computation type:] Simple function application.++[Binding strategy:] The bound function is applied to the input value.+@'Identity' x >>= f == 'Identity' (f x)@++[Useful for:] Monads can be derived from monad transformers applied to the+'Identity' monad.++[Zero and plus:] None.++[Example type:] @'Identity' a@++The @Identity@ monad is a monad that does not embody any computational strategy.+It simply applies the bound function to its input without any modification.+Computationally, there is no reason to use the @Identity@ monad+instead of the much simpler act of simply applying functions to their arguments.+The purpose of the @Identity@ monad is its fundamental role in the theory+of monad transformers.+Any monad transformer applied to the @Identity@ monad yields a non-transformer+version of that monad.+-}++module Control.Monad.Identity (+    module Data.Functor.Identity,++    module Control.Monad,+    module Control.Monad.Fix,+   ) where++import Control.Monad+import Control.Monad.Fix+import Data.Functor.Identity
Control/Monad/List.hs view
@@ -3,9 +3,9 @@ -- Module      :  Control.Monad.List -- Copyright   :  (c) Andy Gill 2001, --                (c) Oregon Graduate Institute of Science and Technology, 2001--- License     :  BSD-style (see the file libraries/base/LICENSE)+-- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  libraries@haskell.org+-- Maintainer  :  ross@soi.city.ac.uk -- Stability   :  experimental -- Portability :  portable --
Control/Monad/RWS.hs view
@@ -3,9 +3,9 @@ -- Module      :  Control.Monad.RWS -- Copyright   :  (c) Andy Gill 2001, --                (c) Oregon Graduate Institute of Science and Technology, 2001--- License     :  BSD-style (see the file libraries/base/LICENSE)+-- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  libraries@haskell.org+-- Maintainer  :  ross@soi.city.ac.uk -- Stability   :  experimental -- Portability :  non-portable (multi-param classes, functional dependencies) --
Control/Monad/RWS/Class.hs view
@@ -1,14 +1,11 @@-{-# LANGUAGE UndecidableInstances #-}--- Search for UndecidableInstances to see why this is needed- ----------------------------------------------------------------------------- -- | -- Module      :  Control.Monad.RWS.Class -- Copyright   :  (c) Andy Gill 2001, --                (c) Oregon Graduate Institute of Science and Technology, 2001--- License     :  BSD-style (see the file libraries/base/LICENSE)+-- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  libraries@haskell.org+-- Maintainer  :  ross@soi.city.ac.uk -- Stability   :  experimental -- Portability :  non-portable (multi-param classes, functional dependencies) --@@ -28,36 +25,7 @@     module Control.Monad.Writer.Class,   ) where -import Control.Monad.Reader.Class-import Control.Monad.State.Class-import Control.Monad.Writer.Class--import Control.Monad.Trans.Error(Error, ErrorT)-import Control.Monad.Trans.Maybe(MaybeT)-import Control.Monad.Trans.Identity(IdentityT)-import Control.Monad.Trans.RWS.Lazy as Lazy (RWST)-import qualified Control.Monad.Trans.RWS.Strict as Strict (RWST)--import Data.Monoid--class (Monoid w, MonadReader r m, MonadWriter w m, MonadState s m)-   => MonadRWS r w s m | m -> r, m -> w, m -> s--instance (Monoid w, Monad m) => MonadRWS r w s (Lazy.RWST r w s m)--instance (Monoid w, Monad m) => MonadRWS r w s (Strict.RWST r w s m)- ------------------------------------------------------------------------------- Instances for other mtl transformers- --- This instance needs UndecidableInstances, because--- it does not satisfy the coverage condition-instance (Error e, MonadRWS r w s m) => MonadRWS r w s (ErrorT e m)- --- This instance needs UndecidableInstances, because--- it does not satisfy the coverage condition-instance (MonadRWS r w s m) => MonadRWS r w s (IdentityT m)- --- This instance needs UndecidableInstances, because--- it does not satisfy the coverage condition-instance (MonadRWS r w s m) => MonadRWS r w s (MaybeT m)+import "mtl" Control.Monad.RWS.Class+import "mtl" Control.Monad.Reader.Class+import "mtl" Control.Monad.State.Class+import "mtl" Control.Monad.Writer.Class
Control/Monad/RWS/Lazy.hs view
@@ -3,9 +3,9 @@ -- Module      :  Control.Monad.RWS.Lazy -- Copyright   :  (c) Andy Gill 2001, --                (c) Oregon Graduate Institute of Science and Technology, 2001--- License     :  BSD-style (see the file libraries/base/LICENSE)+-- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  libraries@haskell.org+-- Maintainer  :  ross@soi.city.ac.uk -- Stability   :  experimental -- Portability :  non-portable (multi-param classes, functional dependencies) --
Control/Monad/RWS/Strict.hs view
@@ -3,9 +3,9 @@ -- Module      :  Control.Monad.RWS.Strict -- Copyright   :  (c) Andy Gill 2001, --                (c) Oregon Graduate Institute of Science and Technology, 2001--- License     :  BSD-style (see the file libraries/base/LICENSE)+-- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  libraries@haskell.org+-- Maintainer  :  ross@soi.city.ac.uk -- Stability   :  experimental -- Portability :  non-portable (multi-param classes, functional dependencies) --
Control/Monad/Reader.hs view
@@ -4,9 +4,9 @@                (c) Oregon Graduate Institute of Science and Technology 2001,                (c) Jeff Newbern 2003-2007,                (c) Andriy Palamarchuk 2007-License     :  BSD-style (see the file libraries/base/LICENSE)+License     :  BSD-style (see the file LICENSE) -Maintainer  :  libraries@haskell.org+Maintainer  :  ross@soi.city.ac.uk Stability   :  experimental Portability :  non-portable (multi-param classes, functional dependencies) 
Control/Monad/Reader/Class.hs view
@@ -1,14 +1,12 @@-{-# LANGUAGE UndecidableInstances #-}--- Search for UndecidableInstances to see why this is needed {- | Module      :  Control.Monad.Reader.Class Copyright   :  (c) Andy Gill 2001,                (c) Oregon Graduate Institute of Science and Technology 2001,                (c) Jeff Newbern 2003-2007,                (c) Andriy Palamarchuk 2007-License     :  BSD-style (see the file libraries/base/LICENSE)+License     :  BSD-style (see the file LICENSE) -Maintainer  :  libraries@haskell.org+Maintainer  :  ross@soi.city.ac.uk Stability   :  experimental Portability :  non-portable (multi-param classes, functional dependencies) @@ -43,113 +41,4 @@     asks,     ) where -import Control.Monad.Trans.Cont as Cont-import Control.Monad.Trans.Error-import Control.Monad.Trans.Identity-import Control.Monad.Trans.List-import Control.Monad.Trans.Maybe-import Control.Monad.Trans.Reader (ReaderT)-import qualified Control.Monad.Trans.Reader as ReaderT (ask, local)-import qualified Control.Monad.Trans.RWS.Lazy as LazyRWS (RWST, ask, local)-import qualified Control.Monad.Trans.RWS.Strict as StrictRWS (RWST, ask, local)-import Control.Monad.Trans.State.Lazy as Lazy-import Control.Monad.Trans.State.Strict as Strict-import Control.Monad.Trans.Writer.Lazy as Lazy-import Control.Monad.Trans.Writer.Strict as Strict-import Control.Monad.Trans--import Control.Monad-import Data.Monoid---- ------------------------------------------------------------------------------- class MonadReader---  asks for the internal (non-mutable) state.---- | See examples in "Control.Monad.Reader".--- Note, the partially applied function type @(->) r@ is a simple reader monad.--- See the @instance@ declaration below.-class (Monad m) => MonadReader r m | m -> r where-    -- | Retrieves the monad environment.-    ask   :: m r--    -- | Executes a computation in a modified environment.-    local :: (r -> r)	-- ^ The function to modify the environment.-          -> m a	-- ^ @Reader@ to run in the modified environment.-          -> m a---- | Retrieves a function of the current environment.-asks :: (MonadReader r m)-    => (r -> a)		-- ^ The selector function to apply to the environment.-    -> m a-asks f = do-    r <- ask-    return (f r)---- ------------------------------------------------------------------------------- The partially applied function type is a simple reader monad--instance MonadReader r ((->) r) where-    ask       = id-    local f m = m . f--instance (Monad m) => MonadReader r (ReaderT r m) where-    ask = ReaderT.ask-    local = ReaderT.local--instance (Monad m, Monoid w) => MonadReader r (LazyRWS.RWST r w s m) where-    ask = LazyRWS.ask-    local = LazyRWS.local--instance (Monad m, Monoid w) => MonadReader r (StrictRWS.RWST r w s m) where-    ask = StrictRWS.ask-    local = StrictRWS.local---- ------------------------------------------------------------------------------ Instances for other mtl transformers---- Needs UndecidableInstances-instance (MonadReader r' m) => MonadReader r' (ContT r m) where-    ask   = lift ask-    local = Cont.liftLocal ask local---- Needs UndecidableInstances-instance (Error e, MonadReader r m) => MonadReader r (ErrorT e m) where-    ask   = lift ask-    local = mapErrorT . local---- Needs UndecidableInstances-instance (MonadReader r m) => MonadReader r (IdentityT m) where-    ask   = lift ask-    local = mapIdentityT . local---- Needs UndecidableInstances-instance (MonadReader r m) => MonadReader r (ListT m) where-    ask   = lift ask-    local = mapListT . local---- Needs UndecidableInstances-instance (MonadReader r m) => MonadReader r (MaybeT m) where-    ask   = lift ask-    local = mapMaybeT . local---- Needs UndecidableInstances-instance (MonadReader r m) => MonadReader r (Lazy.StateT s m) where-    ask   = lift ask-    local = Lazy.mapStateT . local---- Needs UndecidableInstances-instance (MonadReader r m) => MonadReader r (Strict.StateT s m) where-    ask   = lift ask-    local = Strict.mapStateT . local---- This instance needs UndecidableInstances, because--- it does not satisfy the coverage condition-instance (Monoid w, MonadReader r m) => MonadReader r (Lazy.WriterT w m) where-    ask   = lift ask-    local = Lazy.mapWriterT . local---- This instance needs UndecidableInstances, because--- it does not satisfy the coverage condition-instance (Monoid w, MonadReader r m) => MonadReader r (Strict.WriterT w m) where-    ask   = lift ask-    local = Strict.mapWriterT . local+import "mtl" Control.Monad.Reader.Class
Control/Monad/State.hs view
@@ -3,9 +3,9 @@ -- Module      :  Control.Monad.State -- Copyright   :  (c) Andy Gill 2001, --                (c) Oregon Graduate Institute of Science and Technology, 2001--- License     :  BSD-style (see the file libraries/base/LICENSE)+-- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  libraries@haskell.org+-- Maintainer  :  ross@soi.city.ac.uk -- Stability   :  experimental -- Portability :  non-portable (multi-param classes, functional dependencies) --
Control/Monad/State/Class.hs view
@@ -1,14 +1,11 @@-{-# LANGUAGE UndecidableInstances #-}--- Search for UndecidableInstances to see why this is needed- ----------------------------------------------------------------------------- -- | -- Module      :  Control.Monad.State.Class -- Copyright   :  (c) Andy Gill 2001, --                (c) Oregon Graduate Institute of Science and Technology, 2001--- License     :  BSD-style (see the file libraries/base/LICENSE)+-- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  libraries@haskell.org+-- Maintainer  :  ross@soi.city.ac.uk -- Stability   :  experimental -- Portability :  non-portable (multi-param classes, functional dependencies) --@@ -28,108 +25,4 @@     gets,   ) where -import Control.Monad.Trans (lift)-import Control.Monad.Trans.Cont-import Control.Monad.Trans.Error-import Control.Monad.Trans.Identity-import Control.Monad.Trans.List-import Control.Monad.Trans.Maybe-import Control.Monad.Trans.Reader-import qualified Control.Monad.Trans.RWS.Lazy as LazyRWS (RWST, get, put)-import qualified Control.Monad.Trans.RWS.Strict as StrictRWS (RWST, get, put)-import qualified Control.Monad.Trans.State.Lazy as Lazy (StateT, get, put)-import qualified Control.Monad.Trans.State.Strict as Strict (StateT, get, put)-import Control.Monad.Trans.Writer.Lazy as Lazy-import Control.Monad.Trans.Writer.Strict as Strict--import Control.Monad-import Data.Monoid---- ------------------------------------------------------------------------------ | /get/ returns the state from the internals of the monad.------ /put/ replaces the state inside the monad.--class (Monad m) => MonadState s m | m -> s where-    get :: m s-    put :: s -> m ()---- | Monadic state transformer.------      Maps an old state to a new state inside a state monad.---      The old state is thrown away.------ >      Main> :t modify ((+1) :: Int -> Int)--- >      modify (...) :: (MonadState Int a) => a ()------    This says that @modify (+1)@ acts over any---    Monad that is a member of the @MonadState@ class,---    with an @Int@ state.--modify :: (MonadState s m) => (s -> s) -> m ()-modify f = do-    s <- get-    put (f s)---- | Gets specific component of the state, using a projection function--- supplied.--gets :: (MonadState s m) => (s -> a) -> m a-gets f = do-    s <- get-    return (f s)--instance (Monad m) => MonadState s (Lazy.StateT s m) where-    get = Lazy.get-    put = Lazy.put--instance (Monad m) => MonadState s (Strict.StateT s m) where-    get = Strict.get-    put = Strict.put--instance (Monad m, Monoid w) => MonadState s (LazyRWS.RWST r w s m) where-    get = LazyRWS.get-    put = LazyRWS.put--instance (Monad m, Monoid w) => MonadState s (StrictRWS.RWST r w s m) where-    get = StrictRWS.get-    put = StrictRWS.put---- ------------------------------------------------------------------------------ Instances for other mtl transformers---- Needs UndecidableInstances-instance (MonadState s m) => MonadState s (ContT r m) where-    get = lift get-    put = lift . put--instance (Error e, MonadState s m) => MonadState s (ErrorT e m) where-    get = lift get-    put = lift . put--instance (MonadState s m) => MonadState s (IdentityT m) where-    get = lift get-    put = lift . put--instance (MonadState s m) => MonadState s (ListT m) where-    get = lift get-    put = lift . put--instance (MonadState s m) => MonadState s (MaybeT m) where-    get = lift get-    put = lift . put---- Needs UndecidableInstances-instance (MonadState s m) => MonadState s (ReaderT r m) where-    get = lift get-    put = lift . put---- Needs UndecidableInstances-instance (Monoid w, MonadState s m) => MonadState s (Lazy.WriterT w m) where-    get = lift get-    put = lift . put---- Needs UndecidableInstances-instance (Monoid w, MonadState s m) => MonadState s (Strict.WriterT w m) where-    get = lift get-    put = lift . put+import "mtl" Control.Monad.State.Class
Control/Monad/State/Lazy.hs view
@@ -3,9 +3,9 @@ -- Module      :  Control.Monad.State.Lazy -- Copyright   :  (c) Andy Gill 2001, --                (c) Oregon Graduate Institute of Science and Technology, 2001--- License     :  BSD-style (see the file libraries/base/LICENSE)+-- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  libraries@haskell.org+-- Maintainer  :  ross@soi.city.ac.uk -- Stability   :  experimental -- Portability :  non-portable (multi-param classes, functional dependencies) --
Control/Monad/State/Strict.hs view
@@ -3,9 +3,9 @@ -- Module      :  Control.Monad.State.Strict -- Copyright   :  (c) Andy Gill 2001, --                (c) Oregon Graduate Institute of Science and Technology, 2001--- License     :  BSD-style (see the file libraries/base/LICENSE)+-- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  libraries@haskell.org+-- Maintainer  :  ross@soi.city.ac.uk -- Stability   :  experimental -- Portability :  non-portable (multi-param classes, functional dependencies) --
+ Control/Monad/Trans.hs view
@@ -0,0 +1,34 @@+-----------------------------------------------------------------------------+-- |+-- Module      :  Control.Monad.Trans+-- Copyright   :  (c) Andy Gill 2001,+--                (c) Oregon Graduate Institute of Science and Technology, 2001+-- License     :  BSD-style (see the file LICENSE)+--+-- Maintainer  :  ross@soi.city.ac.uk+-- Stability   :  experimental+-- Portability :  portable+--+-- Classes for monad transformers.+--+-- A monad transformer makes new monad out of an existing monad, such+-- that computations of the old monad may be embedded in the new one.+-- To construct a monad with a desired set of features, one typically+-- starts with a base monad, such as @Identity@, @[]@ or 'IO', and+-- applies a sequence of monad transformers.+--+-- Most monad transformer modules include the special case of applying the+-- transformer to @Identity@.  For example, @State s@ is an abbreviation+-- for @StateT s Identity@.+--+-- Each monad transformer also comes with an operation @run@/XXX/ to+-- unwrap the transformer, exposing a computation of the inner monad.+-----------------------------------------------------------------------------++module Control.Monad.Trans (+    module Control.Monad.Trans.Class,+    module Control.Monad.IO.Class+  ) where++import Control.Monad.IO.Class+import Control.Monad.Trans.Class
Control/Monad/Writer.hs view
@@ -3,9 +3,9 @@ -- Module      :  Control.Monad.Writer -- Copyright   :  (c) Andy Gill 2001, --                (c) Oregon Graduate Institute of Science and Technology, 2001--- License     :  BSD-style (see the file libraries/base/LICENSE)+-- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  libraries@haskell.org+-- Maintainer  :  ross@soi.city.ac.uk -- Stability   :  experimental -- Portability :  non-portable (multi-param classes, functional dependencies) --
Control/Monad/Writer/Class.hs view
@@ -1,14 +1,11 @@-{-# LANGUAGE UndecidableInstances #-}--- Search for UndecidableInstances to see why this is needed- ----------------------------------------------------------------------------- -- | -- Module      :  Control.Monad.Writer.Class -- Copyright   :  (c) Andy Gill 2001, --                (c) Oregon Graduate Institute of Science and Technology, 2001--- License     :  BSD-style (see the file libraries/base/LICENSE)+-- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  libraries@haskell.org+-- Maintainer  :  ross@soi.city.ac.uk -- Stability   :  experimental -- Portability :  non-portable (multi-param classes, functional dependencies) --@@ -27,102 +24,4 @@     censor,   ) where -import Control.Monad-import Control.Monad.Trans.Error as Error-import Control.Monad.Trans.Identity as Identity-import Control.Monad.Trans.Maybe as Maybe-import Control.Monad.Trans.Reader-import qualified Control.Monad.Trans.RWS.Lazy as LazyRWS (-        RWST, tell, listen, pass)-import qualified Control.Monad.Trans.RWS.Strict as StrictRWS (-        RWST, tell, listen, pass)-import Control.Monad.Trans.State.Lazy as Lazy-import Control.Monad.Trans.State.Strict as Strict-import qualified Control.Monad.Trans.Writer.Lazy as Lazy (-        WriterT, tell, listen, pass)-import qualified Control.Monad.Trans.Writer.Strict as Strict (-        WriterT, tell, listen, pass)-import Control.Monad.Trans (lift)-import Data.Monoid---- ------------------------------------------------------------------------------ MonadWriter class------ tell is like tell on the MUD's it shouts to monad--- what you want to be heard. The monad carries this 'packet'--- upwards, merging it if needed (hence the Monoid requirement).------ listen listens to a monad acting, and returns what the monad "said".------ pass lets you provide a writer transformer which changes internals of--- the written object.--class (Monoid w, Monad m) => MonadWriter w m | m -> w where-    tell   :: w -> m ()-    listen :: m a -> m (a, w)-    pass   :: m (a, w -> w) -> m a--listens :: (MonadWriter w m) => (w -> b) -> m a -> m (a, b)-listens f m = do-    ~(a, w) <- listen m-    return (a, f w)--censor :: (MonadWriter w m) => (w -> w) -> m a -> m a-censor f m = pass $ do-    a <- m-    return (a, f)--instance (Monoid w, Monad m) => MonadWriter w (Lazy.WriterT w m) where-    tell   = Lazy.tell-    listen = Lazy.listen-    pass   = Lazy.pass--instance (Monoid w, Monad m) => MonadWriter w (Strict.WriterT w m) where-    tell   = Strict.tell-    listen = Strict.listen-    pass   = Strict.pass--instance (Monoid w, Monad m) => MonadWriter w (LazyRWS.RWST r w s m) where-    tell   = LazyRWS.tell-    listen = LazyRWS.listen-    pass   = LazyRWS.pass--instance (Monoid w, Monad m) => MonadWriter w (StrictRWS.RWST r w s m) where-    tell   = StrictRWS.tell-    listen = StrictRWS.listen-    pass   = StrictRWS.pass---- ------------------------------------------------------------------------------ Instances for other mtl transformers------ All of these instances need UndecidableInstances--instance (Error e, MonadWriter w m) => MonadWriter w (ErrorT e m) where-    tell   = lift . tell-    listen = Error.liftListen listen-    pass   = Error.liftPass pass--instance (MonadWriter w m) => MonadWriter w (IdentityT m) where-    tell   = lift . tell-    listen = Identity.mapIdentityT listen-    pass   = Identity.mapIdentityT pass--instance (MonadWriter w m) => MonadWriter w (MaybeT m) where-    tell   = lift . tell-    listen = Maybe.liftListen listen-    pass   = Maybe.liftPass pass--instance (MonadWriter w m) => MonadWriter w (ReaderT r m) where-    tell   = lift . tell-    listen = mapReaderT listen-    pass   = mapReaderT pass--instance (MonadWriter w m) => MonadWriter w (Lazy.StateT s m) where-    tell   = lift . tell-    listen = Lazy.liftListen listen-    pass   = Lazy.liftPass pass--instance (MonadWriter w m) => MonadWriter w (Strict.StateT s m) where-    tell   = lift . tell-    listen = Strict.liftListen listen-    pass   = Strict.liftPass pass+import "mtl" Control.Monad.Writer.Class
Control/Monad/Writer/Lazy.hs view
@@ -3,9 +3,9 @@ -- Module      :  Control.Monad.Writer.Lazy -- Copyright   :  (c) Andy Gill 2001, --                (c) Oregon Graduate Institute of Science and Technology, 2001--- License     :  BSD-style (see the file libraries/base/LICENSE)+-- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  libraries@haskell.org+-- Maintainer  :  ross@soi.city.ac.uk -- Stability   :  experimental -- Portability :  non-portable (multi-param classes, functional dependencies) --
Control/Monad/Writer/Strict.hs view
@@ -3,9 +3,9 @@ -- Module      :  Control.Monad.Writer.Strict -- Copyright   :  (c) Andy Gill 2001, --                (c) Oregon Graduate Institute of Science and Technology, 2001--- License     :  BSD-style (see the file libraries/base/LICENSE)+-- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  libraries@haskell.org+-- Maintainer  :  ross@soi.city.ac.uk -- Stability   :  experimental -- Portability :  non-portable (multi-param classes, functional dependencies) --
monads-fd.cabal view
@@ -1,5 +1,6 @@ name:         monads-fd-version:      0.0.0.1+version:      0.2.0.0+cabal-version: >= 1.6 license:      BSD3 license-file: LICENSE author:       Andy Gill@@ -7,20 +8,18 @@ category:     Control synopsis:     Monad classes, using functional dependencies description:-    Monad classes using functional dependencies, with instances-    for various monad transformers, inspired by the paper-    /Functional Programming with Overloading and Higher-Order Polymorphism/,-    by Mark P Jones, in /Advanced School of Functional Programming/, 1995-    (<http://web.cecs.pdx.edu/~mpj/pubs/springschool.html>).-    .-    This package is almost a compatible replacement for the @mtl@ package.-    Client packages will need to depend on this one and on @transformers@.+    Now that @mtl@ has been upgraded to depend on @transformers@,+    this package is a backwards compatibility stub re-exporting the+    @mtl@ package. build-type: Simple-exposed-modules:++Library+  exposed-modules:     Control.Monad.Cont     Control.Monad.Cont.Class     Control.Monad.Error     Control.Monad.Error.Class+    Control.Monad.Identity     Control.Monad.List     Control.Monad.RWS     Control.Monad.RWS.Class@@ -32,13 +31,11 @@     Control.Monad.State.Class     Control.Monad.State.Lazy     Control.Monad.State.Strict+    Control.Monad.Trans     Control.Monad.Writer     Control.Monad.Writer.Class     Control.Monad.Writer.Lazy     Control.Monad.Writer.Strict-build-depends: base, transformers >= 0.1.4.0-extensions:-    MultiParamTypeClasses-    FunctionalDependencies-    FlexibleInstances-    TypeSynonymInstances+  build-depends: base < 6, transformers == 0.2.*, mtl == 2.*+  extensions:+    PackageImports