packages feed

transformers 0.4.0.0 → 0.4.1.0

raw patch · 21 files changed

+42/−108 lines, 21 files

Files

Control/Applicative/Backwards.hs view
@@ -12,7 +12,6 @@  module Control.Applicative.Backwards (     Backwards(..),-    forwards,   ) where  import Data.Functor.Classes@@ -24,11 +23,7 @@  -- | The same functor, but with an 'Applicative' instance that performs -- actions in the reverse order.-newtype Backwards f a = Backwards (f a)---- | Inverse of 'Backwards'.-forwards :: Backwards f a -> f a-forwards (Backwards x) = x+newtype Backwards f a = Backwards { forwards :: f a }  instance (Eq1 f, Eq a) => Eq (Backwards f a) where     Backwards x == Backwards y = eq1 x y
Control/Monad/Trans/Class.hs view
@@ -58,6 +58,8 @@  Each monad transformer also comes with an operation @run@/XXX/@T@ to unwrap the transformer, exposing a computation of the inner monad.+(Currently these functions are defined as field labels, but in the next+major release they will be separate functions.)  All of the monad transformers except 'Control.Monad.Trans.Cont.ContT' are functors on the category of monads: in addition to defining a
Control/Monad/Trans/Cont.hs view
@@ -28,7 +28,6 @@     reset, shift,     -- * The ContT monad transformer     ContT(..),-    runContT,     evalContT,     mapContT,     withContT,@@ -107,12 +106,7 @@  -- | The continuation monad transformer. -- Can be used to add continuation handling to other monads.-newtype ContT r m a = ContT ((a -> m r) -> m r)---- | The result of running a CPS computation with a given final continuation.--- (The inverse of 'cont')-runContT :: ContT r m a -> (a -> m r) -> m r-runContT (ContT m) = m+newtype ContT r m a = ContT { runContT :: (a -> m r) -> m r }  -- | The result of running a CPS computation with 'return' as the -- final continuation.
Control/Monad/Trans/Error.hs view
@@ -34,7 +34,6 @@     Error(..),     ErrorList(..),     ErrorT(..),-    runErrorT,     mapErrorT,     -- * Error operations     throwError,@@ -153,7 +152,7 @@ -- -- The 'return' function yields a successful computation, while @>>=@ -- sequences two subcomputations, failing on the first error.-newtype ErrorT e m a = ErrorT (m (Either e a))+newtype ErrorT e m a = ErrorT { runErrorT :: m (Either e a) }  instance (Eq e, Eq1 m, Eq a) => Eq (ErrorT e m a) where     ErrorT x == ErrorT y = eq1 x y@@ -171,10 +170,6 @@ instance (Ord e, Ord1 m) => Ord1 (ErrorT e m) where compare1 = compare instance (Read e, Read1 m) => Read1 (ErrorT e m) where readsPrec1 = readsPrec instance (Show e, Show1 m) => Show1 (ErrorT e m) where showsPrec1 = showsPrec---- | Inverse of 'ErrorT'.-runErrorT :: ErrorT e m a -> m (Either e a)-runErrorT (ErrorT m) = m  -- | Map the unwrapped computation using the given function. --
Control/Monad/Trans/Except.hs view
@@ -27,7 +27,7 @@     mapExcept,     withExcept,     -- * The ExceptT monad transformer-    ExceptT(..),+    ExceptT(ExceptT),     runExceptT,     mapExceptT,     withExceptT,
Control/Monad/Trans/Identity.hs view
@@ -16,7 +16,6 @@ module Control.Monad.Trans.Identity (     -- * The identity monad transformer     IdentityT(..),-    runIdentityT,     mapIdentityT,     -- * Lifting other operations     liftCatch,@@ -35,7 +34,7 @@ import Data.Traversable (Traversable(traverse))  -- | The trivial monad transformer, which maps a monad to an equivalent monad.-newtype IdentityT f a = IdentityT (f a)+newtype IdentityT f a = IdentityT { runIdentityT :: f a }  instance (Eq1 f, Eq a) => Eq (IdentityT f a) where     IdentityT x == IdentityT y = eq1 x y@@ -88,10 +87,6 @@  instance MonadTrans IdentityT where     lift = IdentityT---- | The inverse of 'IdentityT'.-runIdentityT :: IdentityT f a -> f a-runIdentityT (IdentityT m) = m  -- | Lift a unary operation to the new monad. mapIdentityT :: (m a -> n b) -> IdentityT m a -> IdentityT n b
Control/Monad/Trans/List.hs view
@@ -16,7 +16,6 @@ module Control.Monad.Trans.List (     -- * The ListT monad transformer     ListT(..),-    runListT,     mapListT,     -- * Lifting other operations     liftCallCC,@@ -36,7 +35,7 @@ -- | Parameterizable list monad, with an inner monad. -- -- /Note:/ this does not yield a monad unless the argument monad is commutative.-newtype ListT m a = ListT (m [a])+newtype ListT m a = ListT { runListT :: m [a] }  instance (Eq1 m, Eq a) => Eq (ListT m a) where     ListT x == ListT y = eq1 x y@@ -54,10 +53,6 @@ instance (Ord1 m) => Ord1 (ListT m) where compare1 = compare instance (Read1 m) => Read1 (ListT m) where readsPrec1 = readsPrec instance (Show1 m) => Show1 (ListT m) where showsPrec1 = showsPrec---- | The inverse of 'ListT'.-runListT :: ListT m a -> m [a]-runListT (ListT m) = m  -- | Map between 'ListT' computations. --
Control/Monad/Trans/Maybe.hs view
@@ -22,7 +22,6 @@ module Control.Monad.Trans.Maybe (     -- * The MaybeT monad transformer     MaybeT(..),-    runMaybeT,     mapMaybeT,     -- * Conversion     maybeToExceptT,@@ -55,7 +54,7 @@ -- The 'return' function yields a computation that produces that -- value, while @>>=@ sequences two subcomputations, exiting if either -- computation does.-newtype MaybeT m a = MaybeT (m (Maybe a))+newtype MaybeT m a = MaybeT { runMaybeT :: m (Maybe a) }  instance (Eq1 m, Eq a) => Eq (MaybeT m a) where     MaybeT x == MaybeT y = eq1 x y@@ -73,10 +72,6 @@ instance (Ord1 m) => Ord1 (MaybeT m) where compare1 = compare instance (Read1 m) => Read1 (MaybeT m) where readsPrec1 = readsPrec instance (Show1 m) => Show1 (MaybeT m) where showsPrec1 = showsPrec---- | The inverse of 'MaybeT'.-runMaybeT :: MaybeT m a -> m (Maybe a)-runMaybeT (MaybeT m) = m  -- | Transform the computation inside a @MaybeT@. --
Control/Monad/Trans/RWS/Lazy.hs view
@@ -25,7 +25,6 @@     withRWS,     -- * The RWST monad transformer     RWST(..),-    runRWST,     evalRWST,     execRWST,     mapRWST,@@ -116,11 +115,7 @@ -- | A monad transformer adding reading an environment of type @r@, -- collecting an output of type @w@ and updating a state of type @s@ -- to an inner monad @m@.-newtype RWST r w s m a = RWST (r -> s -> m (a, s, w))---- | The inverse of 'RWST'.-runRWST :: RWST r w s m a -> r -> s -> m (a, s, w)-runRWST (RWST m) = m+newtype RWST r w s m a = RWST { runRWST :: r -> s -> m (a, s, w) }  -- | Evaluate a computation with the given initial state and environment, -- returning the final value and output, discarding the final state.
Control/Monad/Trans/RWS/Strict.hs view
@@ -25,7 +25,6 @@     withRWS,     -- * The RWST monad transformer     RWST(..),-    runRWST,     evalRWST,     execRWST,     mapRWST,@@ -116,11 +115,7 @@ -- | A monad transformer adding reading an environment of type @r@, -- collecting an output of type @w@ and updating a state of type @s@ -- to an inner monad @m@.-newtype RWST r w s m a = RWST (r -> s -> m (a, s, w))---- | The inverse of 'RWST'.-runRWST :: RWST r w s m a -> r -> s -> m (a, s, w)-runRWST (RWST m) = m+newtype RWST r w s m a = RWST { runRWST :: r -> s -> m (a, s, w) }  -- | Evaluate a computation with the given initial state and environment, -- returning the final value and output, discarding the final state.
Control/Monad/Trans/Reader.hs view
@@ -26,7 +26,6 @@     withReader,     -- * The ReaderT monad transformer     ReaderT(..),-    runReaderT,     mapReaderT,     withReaderT,     -- * Reader operations@@ -90,12 +89,7 @@ -- -- The 'return' function ignores the environment, while @>>=@ passes -- the inherited environment to both subcomputations.-newtype ReaderT r m a = ReaderT (r -> m a)---- | The underlying computation, as a function of the environment.--- (inverse of 'ReaderT')-runReaderT :: ReaderT r m a -> r -> m a-runReaderT (ReaderT m) = m+newtype ReaderT r m a = ReaderT { runReaderT :: r -> m a }  -- | Transform the computation inside a @ReaderT@. --
Control/Monad/Trans/State/Lazy.hs view
@@ -39,7 +39,6 @@     withState,     -- * The StateT monad transformer     StateT(..),-    runStateT,     evalStateT,     execStateT,     mapStateT,@@ -140,12 +139,7 @@ -- The 'return' function leaves the state unchanged, while @>>=@ uses -- the final state of the first computation as the initial state of -- the second.-newtype StateT s m a = StateT (s -> m (a,s))---- | Evaluate a state computation with the given initial state--- and return the final value and state. (inverse of 'StateT')-runStateT :: StateT s m a -> s -> m (a,s)-runStateT (StateT m) = m+newtype StateT s m a = StateT { runStateT :: s -> m (a,s) }  -- | Evaluate a state computation with the given initial state -- and return the final value, discarding the final state.
Control/Monad/Trans/State/Strict.hs view
@@ -36,7 +36,6 @@     withState,     -- * The StateT monad transformer     StateT(..),-    runStateT,     evalStateT,     execStateT,     mapStateT,@@ -137,12 +136,7 @@ -- The 'return' function leaves the state unchanged, while @>>=@ uses -- the final state of the first computation as the initial state of -- the second.-newtype StateT s m a = StateT (s -> m (a,s))---- | Evaluate a state computation with the given initial state--- and return the final value and state. (inverse of 'StateT')-runStateT :: StateT s m a -> s -> m (a,s)-runStateT (StateT m) = m+newtype StateT s m a = StateT { runStateT :: s -> m (a,s) }  -- | Evaluate a state computation with the given initial state -- and return the final value, discarding the final state.
Control/Monad/Trans/Writer/Lazy.hs view
@@ -29,7 +29,6 @@     mapWriter,     -- * The WriterT monad transformer     WriterT(..),-    runWriterT,     execWriterT,     mapWriterT,     -- * Writer operations@@ -95,7 +94,7 @@ -- -- The 'return' function produces the output 'mempty', while @>>=@ -- combines the outputs of the subcomputations using 'mappend'.-newtype WriterT w m a = WriterT (m (a, w))+newtype WriterT w m a = WriterT { runWriterT :: m (a, w) }  instance (Eq w, Eq1 m, Eq a) => Eq (WriterT w m a) where     WriterT x == WriterT y = eq1 x y@@ -113,10 +112,6 @@ instance (Ord w, Ord1 m) => Ord1 (WriterT w m) where compare1 = compare instance (Read w, Read1 m) => Read1 (WriterT w m) where readsPrec1 = readsPrec instance (Show w, Show1 m) => Show1 (WriterT w m) where showsPrec1 = showsPrec---- | The inverse of 'WriterT'.-runWriterT :: WriterT w m a -> m (a, w)-runWriterT (WriterT m) = m  -- | Extract the output from a writer computation. --
Control/Monad/Trans/Writer/Strict.hs view
@@ -32,7 +32,6 @@     mapWriter,     -- * The WriterT monad transformer     WriterT(..),-    runWriterT,     execWriterT,     mapWriterT,     -- * Writer operations@@ -98,7 +97,7 @@ -- -- The 'return' function produces the output 'mempty', while @>>=@ -- combines the outputs of the subcomputations using 'mappend'.-newtype WriterT w m a = WriterT (m (a, w))+newtype WriterT w m a = WriterT { runWriterT :: m (a, w) }  instance (Eq w, Eq1 m, Eq a) => Eq (WriterT w m a) where     WriterT x == WriterT y = eq1 x y@@ -116,10 +115,6 @@ instance (Ord w, Ord1 m) => Ord1 (WriterT w m) where compare1 = compare instance (Read w, Read1 m) => Read1 (WriterT w m) where readsPrec1 = readsPrec instance (Show w, Show1 m) => Show1 (WriterT w m) where showsPrec1 = showsPrec---- | The inverse of 'WriterT'.-runWriterT :: WriterT w m a -> m (a, w)-runWriterT (WriterT m) = m  -- | Extract the output from a writer computation. --
Data/Functor/Compose.hs view
@@ -11,7 +11,6 @@  module Data.Functor.Compose (     Compose(..),-    getCompose,   ) where  import Data.Functor.Classes@@ -25,11 +24,7 @@ -- | Right-to-left composition of functors. -- The composition of applicative functors is always applicative, -- but the composition of monads is not always a monad.-newtype Compose f g a = Compose (f (g a))---- | Inverse of 'Compose'.-getCompose :: Compose f g a -> f (g a)-getCompose (Compose x) = x+newtype Compose f g a = Compose { getCompose :: f (g a) }  -- Instances of Prelude classes 
Data/Functor/Constant.hs view
@@ -11,7 +11,6 @@  module Data.Functor.Constant (     Constant(..),-    getConstant,   ) where  import Data.Functor.Classes@@ -22,12 +21,17 @@ import Data.Traversable (Traversable(traverse))  -- | Constant functor.-newtype Constant a b = Constant a-    deriving (Eq, Ord, Read, Show)+newtype Constant a b = Constant { getConstant :: a }+    deriving (Eq, Ord) --- | Inverse of 'Constant'.-getConstant :: Constant a b -> a-getConstant (Constant x) = x+-- These instances would be equivalent to the derived instances of the+-- newtype if the field were removed.++instance (Read a) => Read (Constant a b) where+    readsPrec = readsData $ readsUnary "Constant" Constant++instance (Show a) => Show (Constant a b) where+    showsPrec d (Constant x) = showsUnary "Constant" d x  instance (Eq a) => Eq1 (Constant a) where eq1 = (==) instance (Ord a) => Ord1 (Constant a) where compare1 = compare
Data/Functor/Identity.hs view
@@ -22,7 +22,6 @@  module Data.Functor.Identity (     Identity(..),-    runIdentity,   ) where  import Data.Functor.Classes@@ -33,12 +32,17 @@ import Data.Traversable (Traversable(traverse))  -- | Identity functor and monad. (a non-strict monad)-newtype Identity a = Identity a-    deriving (Eq, Ord, Read, Show)+newtype Identity a = Identity { runIdentity :: a }+    deriving (Eq, Ord) --- | Inverse of 'Identity'.-runIdentity :: Identity a -> a-runIdentity (Identity x) = x+-- These instances would be equivalent to the derived instances of the+-- newtype if the field were removed.++instance (Read a) => Read (Identity a) where+    readsPrec = readsData $ readsUnary "Identity" Identity++instance (Show a) => Show (Identity a) where+    showsPrec d (Identity x) = showsUnary "Identity" d x  instance Eq1 Identity where eq1 = (==) instance Ord1 Identity where compare1 = compare
Data/Functor/Reverse.hs view
@@ -12,7 +12,6 @@  module Data.Functor.Reverse (     Reverse(..),-    getReverse,   ) where  import Control.Applicative.Backwards@@ -26,11 +25,7 @@  -- | The same functor, but with 'Foldable' and 'Traversable' instances -- that process the elements in the reverse order.-newtype Reverse f a = Reverse (f a)---- | Inverse of 'Reverse'.-getReverse :: Reverse f a -> f a-getReverse (Reverse x) = x+newtype Reverse f a = Reverse { getReverse :: f a }  instance (Eq1 f, Eq a) => Eq (Reverse f a) where     Reverse x == Reverse y = eq1 x y
changelog view
@@ -1,5 +1,8 @@ -*-change-log-*- +0.4.1.0 Ross Paterson <ross@soi.city.ac.uk> May 2014+	* Reverted to record syntax for newtypes until next major release+ 0.4.0.0 Ross Paterson <ross@soi.city.ac.uk> May 2014 	* Added Sum type 	* Added modify', a strict version of modify, to the state monads
transformers.cabal view
@@ -1,5 +1,5 @@ name:         transformers-version:      0.4.0.0+version:      0.4.1.0 license:      BSD3 license-file: LICENSE author:       Andy Gill, Ross Paterson