monads-fd 0.0.0.1 → 0.1.0.0
raw patch · 10 files changed
+103/−40 lines, 10 filesdep ~basedep ~transformersPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, transformers
API changes (from Hackage documentation)
- Control.Monad.Cont.Class: instance (Monad m) => MonadCont (ContT r m)
- Control.Monad.Error.Class: instance MonadError IOError IO
+ Control.Monad.Cont.Class: instance MonadCont (ContT r m)
+ Control.Monad.Error.Class: instance MonadError IOException IO
Files
- Control/Monad/Cont.hs +1/−1
- Control/Monad/Cont/Class.hs +2/−2
- Control/Monad/Error/Class.hs +7/−4
- Control/Monad/Identity.hs +39/−0
- Control/Monad/RWS/Class.hs +3/−9
- Control/Monad/Reader/Class.hs +4/−12
- Control/Monad/State/Class.hs +4/−5
- Control/Monad/Trans.hs +34/−0
- Control/Monad/Writer/Class.hs +5/−3
- monads-fd.cabal +4/−4
Control/Monad/Cont.hs view
@@ -7,7 +7,7 @@ Maintainer : libraries@haskell.org 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
@@ -7,7 +7,7 @@ Maintainer : libraries@haskell.org Stability : experimental-Portability : non-portable (multi-parameter type classes)+Portability : portable [Computation type:] Computations which can be interrupted and resumed. @@ -90,7 +90,7 @@ -} callCC :: ((a -> m b) -> m a) -> m a -instance (Monad m) => MonadCont (ContT r m) where+instance MonadCont (ContT r m) where callCC = ContT.callCC -- ---------------------------------------------------------------------------
Control/Monad/Error/Class.hs view
@@ -50,12 +50,12 @@ 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.Trans.Class (lift)+import Control.Exception (IOException) import Control.Monad import Control.Monad.Instances () import Data.Monoid-import System.IO {- | The strategy of combining computations that can throw exceptions@@ -69,7 +69,7 @@ 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@.+other than @'Either' 'String'@ or @'Either' 'IOError'@. In these cases you will have to explicitly define instances of the 'Error' and\/or 'MonadError' classes. -}@@ -88,7 +88,7 @@ -} catchError :: m a -> (e -> m a) -> m a -instance MonadError IOError IO where+instance MonadError IOException IO where throwError = ioError catchError = catch @@ -106,6 +106,9 @@ -- --------------------------------------------------------------------------- -- Instances for other mtl transformers+--+-- All of these instances need UndecidableInstances,+-- because they do not satisfy the coverage condition. instance (MonadError e m) => MonadError e (IdentityT m) where throwError = lift . throwError
+ Control/Monad/Identity.hs view
@@ -0,0 +1,39 @@+{- |+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 libraries/base/LICENSE)++Maintainer : libraries@haskell.org+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+ ) where++import Data.Functor.Identity
Control/Monad/RWS/Class.hs view
@@ -44,20 +44,14 @@ => 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+--+-- All of these instances need UndecidableInstances,+-- because they do not satisfy the coverage condition. --- 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)
Control/Monad/Reader/Class.hs view
@@ -56,8 +56,8 @@ 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.Trans.Class (lift) import Control.Monad import Data.Monoid @@ -106,50 +106,42 @@ -- --------------------------------------------------------------------------- -- Instances for other mtl transformers+--+-- All of these instances need UndecidableInstances,+-- because they do not satisfy the coverage condition. --- 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
Control/Monad/State/Class.hs view
@@ -28,7 +28,6 @@ gets, ) where -import Control.Monad.Trans (lift) import Control.Monad.Trans.Cont import Control.Monad.Trans.Error import Control.Monad.Trans.Identity@@ -42,6 +41,7 @@ import Control.Monad.Trans.Writer.Lazy as Lazy import Control.Monad.Trans.Writer.Strict as Strict +import Control.Monad.Trans.Class (lift) import Control.Monad import Data.Monoid @@ -97,8 +97,10 @@ -- --------------------------------------------------------------------------- -- Instances for other mtl transformers+--+-- All of these instances need UndecidableInstances,+-- because they do not satisfy the coverage condition. --- Needs UndecidableInstances instance (MonadState s m) => MonadState s (ContT r m) where get = lift get put = lift . put@@ -119,17 +121,14 @@ 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
+ 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 libraries/base/LICENSE)+--+-- Maintainer : libraries@haskell.org+-- 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/Class.hs view
@@ -27,7 +27,6 @@ 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@@ -42,7 +41,9 @@ WriterT, tell, listen, pass) import qualified Control.Monad.Trans.Writer.Strict as Strict ( WriterT, tell, listen, pass)-import Control.Monad.Trans (lift)++import Control.Monad.Trans.Class (lift)+import Control.Monad import Data.Monoid -- ---------------------------------------------------------------------------@@ -95,7 +96,8 @@ -- --------------------------------------------------------------------------- -- Instances for other mtl transformers ----- All of these instances need UndecidableInstances+-- All of these instances need UndecidableInstances,+-- because they do not satisfy the coverage condition. instance (Error e, MonadWriter w m) => MonadWriter w (ErrorT e m) where tell = lift . tell
monads-fd.cabal view
@@ -1,5 +1,5 @@ name: monads-fd-version: 0.0.0.1+version: 0.1.0.0 license: BSD3 license-file: LICENSE author: Andy Gill@@ -14,13 +14,13 @@ (<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@. build-type: Simple 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 +32,13 @@ 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+build-depends: base < 6, transformers >= 0.2 extensions: MultiParamTypeClasses FunctionalDependencies FlexibleInstances- TypeSynonymInstances