packages feed

transformers 0.4.2.0 → 0.4.3.0

raw patch · 29 files changed

+159/−71 lines, 29 files

Files

Control/Applicative/Backwards.hs view
@@ -8,7 +8,7 @@ -- Copyright   :  (c) Russell O'Connor 2009 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  libraries@haskell.org+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --
Control/Applicative/Lift.hs view
@@ -8,7 +8,7 @@ -- Copyright   :  (c) Ross Paterson 2010 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --@@ -96,7 +96,7 @@  -- | Apply a transformation to the other computation. mapLift :: (f a -> g a) -> Lift f a -> Lift g a-mapLift f (Pure x) = Pure x+mapLift _ (Pure x) = Pure x mapLift f (Other e) = Other (f e)  -- | An applicative functor that collects a monoid (e.g. lists) of errors.@@ -125,5 +125,5 @@ runErrors (Pure x) = Right x  -- | Report an error.-failure :: (Monoid e) => e -> Errors e a+failure :: e -> Errors e a failure e = Other (Constant e)
Control/Monad/IO/Class.hs view
@@ -9,7 +9,7 @@ --                (c) Oregon Graduate Institute of Science and Technology, 2001 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --
Control/Monad/Signatures.hs view
@@ -4,11 +4,12 @@ -- Copyright   :  (c) Ross Paterson 2012 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable -- -- Signatures for monad operations that require specialized lifting.+-- Each signature has a uniformity property that the lifting should satisfy. -----------------------------------------------------------------------------  module Control.Monad.Signatures (@@ -17,16 +18,32 @@  -- | Signature of the @callCC@ operation, -- introduced in "Control.Monad.Trans.Cont".+-- Any lifting function @liftCallCC@ should satisfy+--+-- * @'lift' (f k) = f' ('lift' . k) => 'lift' (cf f) = liftCallCC cf f'@+-- type CallCC m a b = ((a -> m b) -> m a) -> m a  -- | Signature of the @catchE@ operation, -- introduced in "Control.Monad.Trans.Except".+-- Any lifting function @liftCatch@ should satisfy+--+-- * @'lift' (cf m f) = liftCatch ('lift' . cf) ('lift' f)@+-- type Catch e m a = m a -> (e -> m a) -> m a  -- | Signature of the @listen@ operation, -- introduced in "Control.Monad.Trans.Writer".+-- Any lifting function @liftListen@ should satisfy+--+-- * @'lift' . liftListen = liftListen . 'lift'@+-- type Listen w m a = m a -> m (a, w)  -- | Signature of the @pass@ operation, -- introduced in "Control.Monad.Trans.Writer".+-- Any lifting function @liftPass@ should satisfy+--+-- * @'lift' . liftPass = liftPass . 'lift'@+-- type Pass w m a =  m (a, w -> w) -> m a
Control/Monad/Trans/Class.hs view
@@ -9,7 +9,7 @@ --                (c) Oregon Graduate Institute of Science and Technology, 2001 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --@@ -79,7 +79,8 @@ In a sequence of monad transformers, most of these operations.can be lifted through other transformers using 'lift' or the @map@/XXX/@T@ combinator, but a few with more complex type signatures require-specialized lifting combinators, called @lift@/Op/.+specialized lifting combinators, called @lift@/Op/+(see "Control.Monad.Signatures"). -}  {- $strict
Control/Monad/Trans/Cont.hs view
@@ -8,7 +8,7 @@ -- Copyright   :  (c) The University of Glasgow 2001 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --@@ -66,9 +66,10 @@  -- | The result of running a CPS computation with a given final continuation. -- (The inverse of 'cont')-runCont :: Cont r a	-- ^ continuation computation (@Cont@).-    -> (a -> r)		-- ^ the final continuation, which produces-			-- the final result (often 'id').+runCont+    :: Cont r a         -- ^ continuation computation (@Cont@).+    -> (a -> r)         -- ^ the final continuation, which produces+                        -- the final result (often 'id').     -> r runCont m k = runIdentity (runContT m (Identity . k)) 
Control/Monad/Trans/Error.hs view
@@ -11,7 +11,7 @@ --                (c) Andriy Palamarchuk 2006 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --@@ -230,7 +230,7 @@         Right r -> r         _       -> error "empty mfix argument" -instance (Error e) => MonadTrans (ErrorT e) where+instance MonadTrans (ErrorT e) where     lift m = ErrorT $ do         a <- m         return (Right a)@@ -243,7 +243,7 @@ -- * @'runErrorT' ('throwError' e) = 'return' ('Left' e)@ -- -- * @'throwError' e >>= m = 'throwError' e@-throwError :: (Monad m, Error e) => e -> ErrorT e m a+throwError :: (Monad m) => e -> ErrorT e m a throwError l = ErrorT $ return (Left l)  -- | Handle an error.@@ -251,7 +251,7 @@ -- * @'catchError' h ('lift' m) = 'lift' m@ -- -- * @'catchError' h ('throwError' e) = h e@-catchError :: (Monad m, Error e) =>+catchError :: (Monad m) =>     ErrorT e m a                -- ^ the inner computation     -> (e -> ErrorT e m a)      -- ^ a handler for errors in the inner                                 -- computation
Control/Monad/Trans/Except.hs view
@@ -8,7 +8,7 @@ -- Copyright   :  (C) 2013 Ross Paterson -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --@@ -62,7 +62,7 @@ -- Computations are either exceptions or normal values. -- -- The 'return' function returns a normal value, while @>>=@ exits on--- the first exception.  For a variant that continies after an error+-- the first exception.  For a variant that continues after an error -- and collects all the errors, see 'Control.Applicative.Lift.Errors'. type Except e = ExceptT e Identity 
Control/Monad/Trans/Identity.hs view
@@ -8,7 +8,7 @@ -- Copyright   :  (c) 2007 Magnus Therning -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --
Control/Monad/Trans/List.hs view
@@ -9,7 +9,7 @@ --                (c) Oregon Graduate Institute of Science and Technology, 2001 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --
Control/Monad/Trans/Maybe.hs view
@@ -8,7 +8,7 @@ -- Copyright   :  (c) 2007 Yitzak Gale, Eric Kidd -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --
Control/Monad/Trans/RWS.hs view
@@ -5,7 +5,7 @@ --                (c) Oregon Graduate Institute of Science and Technology, 2001 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --
Control/Monad/Trans/RWS/Lazy.hs view
@@ -9,7 +9,7 @@ --                (c) Oregon Graduate Institute of Science and Technology, 2001 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --@@ -205,7 +205,7 @@ -- | Execute a computation in a modified environment -- -- * @'runRWST' ('local' f m) r s = 'runRWST' m (f r) s@-local :: (Monoid w, Monad m) => (r -> r) -> RWST r w s m a -> RWST r w s m a+local :: (r -> r) -> RWST r w s m a -> RWST r w s m a local f m = RWST $ \ r s -> runRWST m (f r) s  -- | Retrieve a function of the current environment.@@ -222,14 +222,14 @@ writer (a, w) = RWST $ \ _ s -> return (a, s, w)  -- | @'tell' w@ is an action that produces the output @w@.-tell :: (Monoid w, Monad m) => w -> RWST r w s m ()+tell :: (Monad m) => w -> RWST r w s m () tell w = RWST $ \ _ s -> return ((),s,w)  -- | @'listen' m@ is an action that executes the action @m@ and adds its -- output to the value of the computation. -- -- * @'runRWST' ('listen' m) r s = 'liftM' (\\ (a, w) -> ((a, w), w)) ('runRWST' m r s)@-listen :: (Monoid w, Monad m) => RWST r w s m a -> RWST r w s m (a, w)+listen :: (Monad m) => RWST r w s m a -> RWST r w s m (a, w) listen m = RWST $ \ r s -> do     ~(a, s', w) <- runRWST m r s     return ((a, w), s', w)@@ -240,7 +240,7 @@ -- * @'listens' f m = 'liftM' (id *** f) ('listen' m)@ -- -- * @'runRWST' ('listens' f m) r s = 'liftM' (\\ (a, w) -> ((a, f w), w)) ('runRWST' m r s)@-listens :: (Monoid w, Monad m) => (w -> b) -> RWST r w s m a -> RWST r w s m (a, b)+listens :: (Monad m) => (w -> b) -> RWST r w s m a -> RWST r w s m (a, b) listens f m = RWST $ \ r s -> do     ~(a, s', w) <- runRWST m r s     return ((a, f w), s', w)@@ -250,7 +250,7 @@ -- to the output. -- -- * @'runRWST' ('pass' m) r s = 'liftM' (\\ ((a, f), w) -> (a, f w)) ('runRWST' m r s)@-pass :: (Monoid w, Monad m) => RWST r w s m (a, w -> w) -> RWST r w s m a+pass :: (Monad m) => RWST r w s m (a, w -> w) -> RWST r w s m a pass m = RWST $ \ r s -> do     ~((a, f), s', w) <- runRWST m r s     return (a, s', f w)@@ -262,7 +262,7 @@ -- * @'censor' f m = 'pass' ('liftM' (\\ x -> (x,f)) m)@ -- -- * @'runRWST' ('censor' f m) r s = 'liftM' (\\ (a, w) -> (a, f w)) ('runRWST' m r s)@-censor :: (Monoid w, Monad m) => (w -> w) -> RWST r w s m a -> RWST r w s m a+censor :: (Monad m) => (w -> w) -> RWST r w s m a -> RWST r w s m a censor f m = RWST $ \ r s -> do     ~(a, s', w) <- runRWST m r s     return (a, s', f w)
Control/Monad/Trans/RWS/Strict.hs view
@@ -9,7 +9,7 @@ --                (c) Oregon Graduate Institute of Science and Technology, 2001 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --@@ -205,7 +205,7 @@ -- | Execute a computation in a modified environment -- -- * @'runRWST' ('local' f m) r s = 'runRWST' m (f r) s@-local :: (Monoid w, Monad m) => (r -> r) -> RWST r w s m a -> RWST r w s m a+local :: (r -> r) -> RWST r w s m a -> RWST r w s m a local f m = RWST $ \ r s -> runRWST m (f r) s  -- | Retrieve a function of the current environment.@@ -222,14 +222,14 @@ writer (a, w) = RWST $ \ _ s -> return (a, s, w)  -- | @'tell' w@ is an action that produces the output @w@.-tell :: (Monoid w, Monad m) => w -> RWST r w s m ()+tell :: (Monad m) => w -> RWST r w s m () tell w = RWST $ \ _ s -> return ((),s,w)  -- | @'listen' m@ is an action that executes the action @m@ and adds its -- output to the value of the computation. -- -- * @'runRWST' ('listen' m) r s = 'liftM' (\\ (a, w) -> ((a, w), w)) ('runRWST' m r s)@-listen :: (Monoid w, Monad m) => RWST r w s m a -> RWST r w s m (a, w)+listen :: (Monad m) => RWST r w s m a -> RWST r w s m (a, w) listen m = RWST $ \ r s -> do     (a, s', w) <- runRWST m r s     return ((a, w), s', w)@@ -240,7 +240,7 @@ -- * @'listens' f m = 'liftM' (id *** f) ('listen' m)@ -- -- * @'runRWST' ('listens' f m) r s = 'liftM' (\\ (a, w) -> ((a, f w), w)) ('runRWST' m r s)@-listens :: (Monoid w, Monad m) => (w -> b) -> RWST r w s m a -> RWST r w s m (a, b)+listens :: (Monad m) => (w -> b) -> RWST r w s m a -> RWST r w s m (a, b) listens f m = RWST $ \ r s -> do     (a, s', w) <- runRWST m r s     return ((a, f w), s', w)@@ -250,7 +250,7 @@ -- to the output. -- -- * @'runRWST' ('pass' m) r s = 'liftM' (\\ ((a, f), w) -> (a, f w)) ('runRWST' m r s)@-pass :: (Monoid w, Monad m) => RWST r w s m (a, w -> w) -> RWST r w s m a+pass :: (Monad m) => RWST r w s m (a, w -> w) -> RWST r w s m a pass m = RWST $ \ r s -> do     ((a, f), s', w) <- runRWST m r s     return (a, s', f w)@@ -262,7 +262,7 @@ -- * @'censor' f m = 'pass' ('liftM' (\\ x -> (x,f)) m)@ -- -- * @'runRWST' ('censor' f m) r s = 'liftM' (\\ (a, w) -> (a, f w)) ('runRWST' m r s)@-censor :: (Monoid w, Monad m) => (w -> w) -> RWST r w s m a -> RWST r w s m a+censor :: (Monad m) => (w -> w) -> RWST r w s m a -> RWST r w s m a censor f m = RWST $ \ r s -> do     (a, s', w) <- runRWST m r s     return (a, s', f w)
Control/Monad/Trans/Reader.hs view
@@ -9,7 +9,7 @@ --                (c) Oregon Graduate Institute of Science and Technology, 2001 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --@@ -66,8 +66,9 @@  -- | Runs a @Reader@ and extracts the final value from it. -- (The inverse of 'reader'.)-runReader :: Reader r a		-- ^ A @Reader@ to run.-    -> r			-- ^ An initial environment.+runReader+     :: Reader r a      -- ^ A @Reader@ to run.+    -> r                -- ^ An initial environment.     -> a runReader m = runIdentity . runReaderT m @@ -152,8 +153,8 @@ -- (a specialization of 'withReaderT'). -- -- * @'runReaderT' ('local' f m) = 'runReaderT' m . f@-local :: (Monad m)-    => (r -> r)         -- ^ The function to modify the environment.+local+    :: (r -> r)         -- ^ The function to modify the environment.     -> ReaderT r m a    -- ^ Computation to run in the modified environment.     -> ReaderT r m a local = withReaderT
Control/Monad/Trans/State.hs view
@@ -5,7 +5,7 @@ --                (c) Oregon Graduate Institute of Science and Technology, 2001 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --
Control/Monad/Trans/State/Lazy.hs view
@@ -9,7 +9,7 @@ --                (c) Oregon Graduate Institute of Science and Technology, 2001 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --@@ -252,7 +252,7 @@  -- | In-situ lifting of a @callCC@ operation to the new monad. -- This version uses the current state on entering the continuation.--- It does not satisfy the laws of a monad transformer.+-- It does not satisfy the uniformity property (see "Control.Monad.Signatures"). liftCallCC' :: CallCC m (a,s) (b,s) -> CallCC (StateT s m) a b liftCallCC' callCC f = StateT $ \ s ->     callCC $ \ c ->
Control/Monad/Trans/State/Strict.hs view
@@ -9,7 +9,7 @@ --                (c) Oregon Graduate Institute of Science and Technology, 2001 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --@@ -249,7 +249,7 @@  -- | In-situ lifting of a @callCC@ operation to the new monad. -- This version uses the current state on entering the continuation.--- It does not satisfy the laws of a monad transformer.+-- It does not satisfy the uniformity property (see "Control.Monad.Signatures"). liftCallCC' :: CallCC m (a,s) (b,s) -> CallCC (StateT s m) a b liftCallCC' callCC f = StateT $ \ s ->     callCC $ \ c ->
Control/Monad/Trans/Writer.hs view
@@ -5,7 +5,7 @@ --                (c) Oregon Graduate Institute of Science and Technology, 2001 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --
Control/Monad/Trans/Writer/Lazy.hs view
@@ -9,7 +9,7 @@ --                (c) Oregon Graduate Institute of Science and Technology, 2001 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --@@ -175,14 +175,14 @@     liftIO = lift . liftIO  -- | @'tell' w@ is an action that produces the output @w@.-tell :: (Monoid w, Monad m) => w -> WriterT w m ()+tell :: (Monad m) => w -> WriterT w m () tell w = writer ((), w)  -- | @'listen' m@ is an action that executes the action @m@ and adds its -- output to the value of the computation. -- -- * @'runWriterT' ('listen' m) = 'liftM' (\\ (a, w) -> ((a, w), w)) ('runWriterT' m)@-listen :: (Monoid w, Monad m) => WriterT w m a -> WriterT w m (a, w)+listen :: (Monad m) => WriterT w m a -> WriterT w m (a, w) listen m = WriterT $ do     ~(a, w) <- runWriterT m     return ((a, w), w)@@ -193,7 +193,7 @@ -- * @'listens' f m = 'liftM' (id *** f) ('listen' m)@ -- -- * @'runWriterT' ('listens' f m) = 'liftM' (\\ (a, w) -> ((a, f w), w)) ('runWriterT' m)@-listens :: (Monoid w, Monad m) => (w -> b) -> WriterT w m a -> WriterT w m (a, b)+listens :: (Monad m) => (w -> b) -> WriterT w m a -> WriterT w m (a, b) listens f m = WriterT $ do     ~(a, w) <- runWriterT m     return ((a, f w), w)@@ -203,7 +203,7 @@ -- to the output. -- -- * @'runWriterT' ('pass' m) = 'liftM' (\\ ((a, f), w) -> (a, f w)) ('runWriterT' m)@-pass :: (Monoid w, Monad m) => WriterT w m (a, w -> w) -> WriterT w m a+pass :: (Monad m) => WriterT w m (a, w -> w) -> WriterT w m a pass m = WriterT $ do     ~((a, f), w) <- runWriterT m     return (a, f w)@@ -215,7 +215,7 @@ -- * @'censor' f m = 'pass' ('liftM' (\\ x -> (x,f)) m)@ -- -- * @'runWriterT' ('censor' f m) = 'liftM' (\\ (a, w) -> (a, f w)) ('runWriterT' m)@-censor :: (Monoid w, Monad m) => (w -> w) -> WriterT w m a -> WriterT w m a+censor :: (Monad m) => (w -> w) -> WriterT w m a -> WriterT w m a censor f m = WriterT $ do     ~(a, w) <- runWriterT m     return (a, f w)
Control/Monad/Trans/Writer/Strict.hs view
@@ -9,7 +9,7 @@ --                (c) Oregon Graduate Institute of Science and Technology, 2001 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --@@ -178,14 +178,14 @@     liftIO = lift . liftIO  -- | @'tell' w@ is an action that produces the output @w@.-tell :: (Monoid w, Monad m) => w -> WriterT w m ()+tell :: (Monad m) => w -> WriterT w m () tell w = writer ((), w)  -- | @'listen' m@ is an action that executes the action @m@ and adds its -- output to the value of the computation. -- -- * @'runWriterT' ('listen' m) = 'liftM' (\\ (a, w) -> ((a, w), w)) ('runWriterT' m)@-listen :: (Monoid w, Monad m) => WriterT w m a -> WriterT w m (a, w)+listen :: (Monad m) => WriterT w m a -> WriterT w m (a, w) listen m = WriterT $ do     (a, w) <- runWriterT m     return ((a, w), w)@@ -196,7 +196,7 @@ -- * @'listens' f m = 'liftM' (id *** f) ('listen' m)@ -- -- * @'runWriterT' ('listens' f m) = 'liftM' (\\ (a, w) -> ((a, f w), w)) ('runWriterT' m)@-listens :: (Monoid w, Monad m) => (w -> b) -> WriterT w m a -> WriterT w m (a, b)+listens :: (Monad m) => (w -> b) -> WriterT w m a -> WriterT w m (a, b) listens f m = WriterT $ do     (a, w) <- runWriterT m     return ((a, f w), w)@@ -206,7 +206,7 @@ -- to the output. -- -- * @'runWriterT' ('pass' m) = 'liftM' (\\ ((a, f), w) -> (a, f w)) ('runWriterT' m)@-pass :: (Monoid w, Monad m) => WriterT w m (a, w -> w) -> WriterT w m a+pass :: (Monad m) => WriterT w m (a, w -> w) -> WriterT w m a pass m = WriterT $ do     ((a, f), w) <- runWriterT m     return (a, f w)@@ -218,7 +218,7 @@ -- * @'censor' f m = 'pass' ('liftM' (\\ x -> (x,f)) m)@ -- -- * @'runWriterT' ('censor' f m) = 'liftM' (\\ (a, w) -> (a, f w)) ('runWriterT' m)@-censor :: (Monoid w, Monad m) => (w -> w) -> WriterT w m a -> WriterT w m a+censor :: (Monad m) => (w -> w) -> WriterT w m a -> WriterT w m a censor f m = WriterT $ do     (a, w) <- runWriterT m     return (a, f w)
Data/Functor/Classes.hs view
@@ -8,11 +8,30 @@ -- Copyright   :  (c) Ross Paterson 2013 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable ----- Prelude classes, lifted to unary type constructors.+-- Liftings of the Prelude classes 'Eq', 'Ord', 'Read' and 'Show' to+-- unary type constructors.+--+-- These classes are needed to express the constraints on arguments of+-- transformers in portable Haskell.  Thus for a new transformer @T@,+-- one might write instances like+--+-- > instance (Eq1 f) => Eq (T f a) where ...+-- > instance (Ord1 f) => Ord (T f a) where ...+-- > instance (Read1 f) => Read (T f a) where ...+-- > instance (Show1 f) => Show (T f a) where ...+--+-- If these instances can be defined, defining instances of the lifted+-- classes is mechanical:+--+-- > instance (Eq1 f) => Eq1 (T f) where eq1 = (==)+-- > instance (Ord1 f) => Ord1 (T f) where compare1 = compare+-- > instance (Read1 f) => Read1 (T f) where readsPrec1 = readsPrec+-- > instance (Show1 f) => Show1 (T f) where showsPrec1 = showsPrec+-- -----------------------------------------------------------------------------  module Data.Functor.Classes (@@ -22,6 +41,7 @@     Read1(..),     Show1(..),     -- * Helper functions+    -- $example     readsData,     readsUnary,     readsUnary1,@@ -31,7 +51,12 @@     showsBinary1,   ) where -import Data.Functor.Identity+#if MIN_VERSION_base(4,8,0)+import Control.Applicative (Const)+#else+import Control.Applicative (Const(Const))+#endif+import Data.Functor.Identity (Identity)  -- | Lifting of the 'Eq' class to unary type constructors. class Eq1 f where@@ -71,13 +96,30 @@ instance (Read a) => Read1 (Either a) where readsPrec1 = readsPrec instance (Show a) => Show1 (Either a) where showsPrec1 = showsPrec --- Instances for other functors+-- Instances for other functors defined in the base package  instance Eq1 Identity where eq1 = (==) instance Ord1 Identity where compare1 = compare instance Read1 Identity where readsPrec1 = readsPrec instance Show1 Identity where showsPrec1 = showsPrec +#if MIN_VERSION_base(4,8,0)+-- Eq, etc instances for Const were introduced in base-4.8+instance (Eq a) => Eq1 (Const a) where eq1 = (==)+instance (Ord a) => Ord1 (Const a) where compare1 = compare+instance (Read a) => Read1 (Const a) where readsPrec1 = readsPrec+instance (Show a) => Show1 (Const a) where showsPrec1 = showsPrec+#else+instance (Eq a) => Eq1 (Const a) where+    eq1 (Const x) (Const y) = x == y+instance (Ord a) => Ord1 (Const a) where+    compare1 (Const x) (Const y) = compare x y+instance (Read a) => Read1 (Const a) where+    readsPrec1 = readsData $ readsUnary "Const" Const+instance (Show a) => Show1 (Const a) where+    showsPrec1 d (Const x) = showsUnary "Const" d x+#endif+ -- Building blocks  -- | @'readsData' p d@ is a parser for datatypes where each alternative@@ -129,3 +171,26 @@ showsBinary1 name d x y = showParen (d > 10) $     showString name . showChar ' ' . showsPrec1 11 x .         showChar ' ' . showsPrec1 11 y++{- $example+These functions can be used to assemble 'Read' and 'Show' instances for+new algebraic types.  For example, given the definition++> data T f a = Zero a | One (f a) | Two (f a) (f a)++a standard 'Read' instance may be defined as++> instance (Read1 f, Read a) => Read (T f a) where+>     readsPrec = readsData $+>         readsUnary "Zero" Zero `mappend`+>         readsUnary1 "One" One `mappend`+>         readsBinary1 "Two" Two++and the corresponding 'Show' instance as++> instance (Show1 f, Show a) => Show (T f a) where+>     showsPrec d (Zero x) = showsUnary "Zero" d x+>     showsPrec d (One x) = showsUnary1 "One" d x+>     showsPrec d (Two x y) = showsBinary1 "Two" d x y++-}
Data/Functor/Compose.hs view
@@ -8,7 +8,7 @@ -- Copyright   :  (c) Ross Paterson 2010 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --
Data/Functor/Constant.hs view
@@ -8,7 +8,7 @@ -- Copyright   :  (c) Ross Paterson 2010 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --
Data/Functor/Product.hs view
@@ -8,7 +8,7 @@ -- Copyright   :  (c) Ross Paterson 2010 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --
Data/Functor/Reverse.hs view
@@ -8,7 +8,7 @@ -- Copyright   :  (c) Russell O'Connor 2009 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  libraries@haskell.org+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --
Data/Functor/Sum.hs view
@@ -8,7 +8,7 @@ -- Copyright   :  (c) Ross Paterson 2014 -- License     :  BSD-style (see the file LICENSE) ----- Maintainer  :  ross@soi.city.ac.uk+-- Maintainer  :  R.Paterson@city.ac.uk -- Stability   :  experimental -- Portability :  portable --
changelog view
@@ -1,5 +1,8 @@ -*-change-log-*- +0.4.3.0 Ross Paterson <R.Paterson@city.ac.uk> Mar 2015+	* Added Eq1, Ord1, Show1 and Read1 instances for Const+ 0.4.2.0 Ross Paterson <ross@soi.city.ac.uk> Nov 2014 	* Dropped compatibility with base-1.x 	* Data.Functor.Identity in base for GHC >= 7.10
transformers.cabal view
@@ -1,9 +1,9 @@ name:         transformers-version:      0.4.2.0+version:      0.4.3.0 license:      BSD3 license-file: LICENSE author:       Andy Gill, Ross Paterson-maintainer:   Ross Paterson <ross@soi.city.ac.uk>+maintainer:   Ross Paterson <R.Paterson@city.ac.uk> category:     Control synopsis:     Concrete functor and monad transformers description:@@ -35,7 +35,7 @@  source-repository head   type: darcs-  location: http://code.haskell.org/~ross/transformers+  location: http://hub.darcs.net/ross/transformers  library   build-depends: base >= 2 && < 6