packages feed

transformers 0.5.4.0 → 0.5.5.0

raw patch · 12 files changed

+75/−10 lines, 12 filesdep ~base

Dependency ranges changed: base

Files

Control/Monad/Trans/Cont.hs view
@@ -59,8 +59,9 @@  {- | Continuation monad.-@Cont r a@ is a CPS computation that produces an intermediate result-of type @a@ within a CPS computation whose final result type is @r@.+@Cont r a@ is a CPS ("continuation-passing style") computation that produces an+intermediate result of type @a@ within a CPS computation whose final result type+is @r@.  The @return@ function simply creates a continuation which passes the value on. @@ -169,6 +170,8 @@     {-# INLINE pure #-}     f <*> v = ContT $ \ c -> runContT f $ \ g -> runContT v (c . g)     {-# INLINE (<*>) #-}+    m *> k = m >>= \_ -> k+    {-# INLINE (*>) #-}  instance Monad (ContT r m) where #if !(MIN_VERSION_base(4,8,0))
Control/Monad/Trans/Except.hs view
@@ -193,6 +193,8 @@                     Left e -> return (Left e)                     Right x -> return (Right (k x))     {-# INLINEABLE (<*>) #-}+    m *> k = m >>= \_ -> k+    {-# INLINE (*>) #-}  instance (Functor m, Monad m, Monoid e) => Alternative (ExceptT e m) where     empty = ExceptT $ return (Left mempty)
Control/Monad/Trans/Identity.hs view
@@ -103,6 +103,10 @@     {-# INLINE pure #-}     (<*>) = lift2IdentityT (<*>)     {-# INLINE (<*>) #-}+    (*>) = lift2IdentityT (*>)+    {-# INLINE (*>) #-}+    (<*) = lift2IdentityT (<*)+    {-# INLINE (<*) #-}  instance (Alternative m) => Alternative (IdentityT m) where     empty = IdentityT empty
Control/Monad/Trans/Maybe.hs view
@@ -30,7 +30,7 @@     -- * The MaybeT monad transformer     MaybeT(..),     mapMaybeT,-    -- * Conversion+    -- * Monad transformations     maybeToExceptT,     exceptToMaybeT,     -- * Lifting other operations@@ -128,7 +128,7 @@     {-# INLINE traverse #-}  instance (Functor m, Monad m) => Applicative (MaybeT m) where-    pure = lift . return+    pure = MaybeT . return . Just     {-# INLINE pure #-}     mf <*> mx = MaybeT $ do         mb_f <- runMaybeT mf@@ -140,6 +140,8 @@                     Nothing -> return Nothing                     Just x  -> return (Just (f x))     {-# INLINE (<*>) #-}+    m *> k = m >>= \_ -> k+    {-# INLINE (*>) #-}  instance (Functor m, Monad m) => Alternative (MaybeT m) where     empty = MaybeT (return Nothing)@@ -153,7 +155,7 @@  instance (Monad m) => Monad (MaybeT m) where #if !(MIN_VERSION_base(4,8,0))-    return = lift . return+    return = MaybeT . return . Just     {-# INLINE return #-} #endif     x >>= f = MaybeT $ do
Control/Monad/Trans/Reader.hs view
@@ -167,7 +167,11 @@         a <- runReaderT m r         runReaderT (k a) r     {-# INLINE (>>=) #-}+#if MIN_VERSION_base(4,8,0)+    (>>) = (*>)+#else     m >> k = ReaderT $ \ r -> runReaderT m r >> runReaderT k r+#endif     {-# INLINE (>>) #-}     fail msg = lift (fail msg)     {-# INLINE fail #-}
Control/Monad/Trans/Select.hs view
@@ -34,9 +34,13 @@     Select,     select,     runSelect,+    mapSelect,     -- * The SelectT monad transformer     SelectT(SelectT),     runSelectT,+    mapSelectT,+    -- * Monad transformation+    selectToContT,     selectToCont,     ) where @@ -65,6 +69,13 @@ runSelect m k = runIdentity (runSelectT m (Identity . k)) {-# INLINE runSelect #-} +-- | Apply a function to transform the result of a selection computation.+--+-- * @'runSelect' ('mapSelect' f m) = f . 'runSelect' m@+mapSelect :: (a -> a) -> Select r a -> Select r a+mapSelect f = mapSelectT (Identity . f . runIdentity)+{-# INLINE mapSelect #-}+ -- | Selection monad transformer. -- -- 'SelectT' is not a functor on the category of monads, and many operations@@ -77,6 +88,16 @@ runSelectT (SelectT g) = g {-# INLINE runSelectT #-} +-- | Apply a function to transform the result of a selection computation.+-- This has a more restricted type than the @map@ operations for other+-- monad transformers, because 'SelectT' does not define a functor in+-- the category of monads.+--+-- * @'runSelectT' ('mapSelectT' f m) = f . 'runSelectT' m@+mapSelectT :: (m a -> m a) -> SelectT r m a -> SelectT r m a+mapSelectT f m = SelectT $ f . runSelectT m+{-# INLINE mapSelectT #-}+ instance (Functor m) => Functor (SelectT r m) where     fmap f (SelectT g) = SelectT (fmap f . g . (. f))     {-# INLINE fmap #-}@@ -89,6 +110,8 @@         f <- gf ((>>= k) . h)         h f     {-# INLINE (<*>) #-}+    m *> k = m >>= \_ -> k+    {-# INLINE (*>) #-}  instance (Functor m, MonadPlus m) => Alternative (SelectT r m) where     empty = mzero@@ -128,6 +151,11 @@     {-# INLINE liftIO #-}  -- | Convert a selection computation to a continuation-passing computation.-selectToCont :: (Monad m) => SelectT r m a -> ContT r m a-selectToCont (SelectT g) = ContT $ \ k -> g k >>= k+selectToContT :: (Monad m) => SelectT r m a -> ContT r m a+selectToContT (SelectT g) = ContT $ \ k -> g k >>= k {-# INLINE selectToCont #-}++-- | Deprecated name for 'selectToContT'.+{-# DEPRECATED selectToCont "Use selectToContT instead" #-}+selectToCont :: (Monad m) => SelectT r m a -> ContT r m a+selectToCont = selectToContT
Control/Monad/Trans/State/Lazy.hs view
@@ -206,7 +206,8 @@         ~(x, s'') <- mx s'         return (f x, s'')     {-# INLINE (<*>) #-}-    (*>) = (>>)+    m *> k = m >>= \_ -> k+    {-# INLINE (*>) #-}  instance (Functor m, MonadPlus m) => Alternative (StateT s m) where     empty = StateT $ \ _ -> mzero
Control/Monad/Trans/State/Strict.hs view
@@ -203,7 +203,8 @@         (x, s'') <- mx s'         return (f x, s'')     {-# INLINE (<*>) #-}-    (*>) = (>>)+    m *> k = m >>= \_ -> k+    {-# INLINE (*>) #-}  instance (Functor m, MonadPlus m) => Alternative (StateT s m) where     empty = StateT $ \ _ -> mzero
Data/Functor/Constant.hs view
@@ -34,6 +34,9 @@ #if MIN_VERSION_base(4,8,0) import Data.Bifunctor (Bifunctor(..)) #endif+#if MIN_VERSION_base(4,9,0)+import Data.Semigroup (Semigroup(..))+#endif #if MIN_VERSION_base(4,10,0) import Data.Bifoldable (Bifoldable(..)) import Data.Bitraversable (Bitraversable(..))@@ -100,6 +103,12 @@     traverse _ (Constant x) = pure (Constant x)     {-# INLINE traverse #-} +#if MIN_VERSION_base(4,9,0)+instance (Semigroup a) => Semigroup (Constant a b) where+    Constant x <> Constant y = Constant (x <> y)+    {-# INLINE (<>) #-}+#endif+ instance (Monoid a) => Applicative (Constant a) where     pure _ = Constant mempty     {-# INLINE pure #-}@@ -109,8 +118,11 @@ instance (Monoid a) => Monoid (Constant a b) where     mempty = Constant mempty     {-# INLINE mempty #-}+#if !MIN_VERSION_base(4,11,0)+    -- From base-4.11, Monoid(mappend) defaults to Semigroup((<>))     Constant x `mappend` Constant y = Constant (x `mappend` y)     {-# INLINE mappend #-}+#endif  #if MIN_VERSION_base(4,8,0) instance Bifunctor Constant where
Data/Functor/Reverse.hs view
@@ -85,8 +85,10 @@  -- | Derived instance. instance (Monad m) => Monad (Reverse m) where+#if !(MIN_VERSION_base(4,8,0))     return a = Reverse (return a)     {-# INLINE return #-}+#endif     m >>= f = Reverse (getReverse m >>= getReverse . f)     {-# INLINE (>>=) #-}     fail msg = Reverse (fail msg)
changelog view
@@ -1,5 +1,11 @@ -*-change-log-*- +0.5.5.0 Ross Paterson <R.Paterson@city.ac.uk> Oct 2017+	* Added mapSelect and mapSelectT+	* Renamed selectToCont to selectToContT for consistency+	* Defined explicit method definitions to fix space leaks+	* Added missing Semigroup instance to `Constant` functor+ 0.5.4.0 Ross Paterson <R.Paterson@city.ac.uk> Feb 2017 	* Migrate Bifoldable and Bitraversable instances for Constant 
transformers.cabal view
@@ -1,5 +1,5 @@ name:         transformers-version:      0.5.4.0+version:      0.5.5.0 license:      BSD3 license-file: LICENSE author:       Andy Gill, Ross Paterson