transformers 0.6.0.6 → 0.6.1.0
raw patch · 8 files changed
+64/−4 lines, 8 files
Files
- Control/Applicative/Backwards.hs +11/−1
- Control/Applicative/Lift.hs +10/−0
- Control/Monad/Trans/Identity.hs +10/−1
- Control/Monad/Trans/State/Lazy.hs +9/−0
- Control/Monad/Trans/State/Strict.hs +9/−0
- Data/Functor/Reverse.hs +10/−1
- changelog +4/−0
- transformers.cabal +1/−1
Control/Applicative/Backwards.hs view
@@ -27,6 +27,9 @@ Backwards(..), ) where +#if MIN_VERSION_base(4,18,0)+import Data.Foldable1 (Foldable1(foldMap1))+#endif import Data.Functor.Classes #if MIN_VERSION_base(4,12,0) import Data.Functor.Contravariant@@ -120,7 +123,14 @@ length (Backwards t) = length t #endif +#if MIN_VERSION_base(4,18,0) -- | Derived instance.+instance (Foldable1 f) => Foldable1 (Backwards f) where+ foldMap1 f (Backwards t) = foldMap1 f t+ {-# INLINE foldMap1 #-}+#endif++-- | Derived instance. instance (Traversable f) => Traversable (Backwards f) where traverse f (Backwards t) = fmap Backwards (traverse f t) {-# INLINE traverse #-}@@ -129,7 +139,7 @@ #if MIN_VERSION_base(4,12,0) -- | Derived instance.-instance Contravariant f => Contravariant (Backwards f) where+instance (Contravariant f) => Contravariant (Backwards f) where contramap f = Backwards . contramap f . forwards {-# INLINE contramap #-} #endif
Control/Applicative/Lift.hs view
@@ -32,6 +32,9 @@ eitherToErrors ) where +#if MIN_VERSION_base(4,18,0)+import Data.Foldable1 (Foldable1(foldMap1))+#endif import Data.Functor.Classes import Control.Applicative@@ -114,6 +117,13 @@ Other _ <|> Pure y = Pure y Other x <|> Other y = Other (x <|> y) {-# INLINE (<|>) #-}++#if MIN_VERSION_base(4,18,0)+instance (Foldable1 f) => Foldable1 (Lift f) where+ foldMap1 f (Pure x) = f x+ foldMap1 f (Other y) = foldMap1 f y+ {-# INLINE foldMap1 #-}+#endif -- | Projection to the other functor. unLift :: (Applicative f) => Lift f a -> f a
Control/Monad/Trans/Identity.hs view
@@ -36,6 +36,9 @@ import Control.Monad.IO.Class (MonadIO(liftIO)) import Control.Monad.Signatures import Control.Monad.Trans.Class (MonadTrans(lift))+#if MIN_VERSION_base(4,18,0)+import Data.Foldable1 (Foldable1(foldMap1))+#endif import Data.Functor.Classes #if MIN_VERSION_base(4,12,0) import Data.Functor.Contravariant@@ -108,6 +111,12 @@ length (IdentityT t) = length t #endif +#if MIN_VERSION_base(4,18,0)+instance (Foldable1 m) => Foldable1 (IdentityT m) where+ foldMap1 f (IdentityT t) = foldMap1 f t+ {-# INLINE foldMap1 #-}+#endif+ instance (Traversable f) => Traversable (IdentityT f) where traverse f (IdentityT a) = IdentityT <$> traverse f a {-# INLINE traverse #-}@@ -171,7 +180,7 @@ {-# INLINE lift #-} #if MIN_VERSION_base(4,12,0)-instance Contravariant f => Contravariant (IdentityT f) where+instance (Contravariant f) => Contravariant (IdentityT f) where contramap f = IdentityT . contramap f . runIdentityT {-# INLINE contramap #-} #endif
Control/Monad/Trans/State/Lazy.hs view
@@ -56,6 +56,7 @@ put, modify, modify',+ modifyM, gets, -- * Lifting other operations liftCallCC,@@ -299,6 +300,14 @@ s <- get put $! f s {-# INLINE modify' #-}++-- | A variant of 'modify' in which the new state is generated by a+-- monadic action.+modifyM :: (Monad m) => (s -> m s) -> StateT s m ()+modifyM f = StateT $ \ s -> do+ s' <- f s+ return ((), s')+{-# INLINE modifyM #-} -- | Get a specific component of the state, using a projection function -- supplied.
Control/Monad/Trans/State/Strict.hs view
@@ -53,6 +53,7 @@ put, modify, modify',+ modifyM, gets, -- * Lifting other operations liftCallCC,@@ -300,6 +301,14 @@ s <- get put $! f s {-# INLINE modify' #-}++-- | A variant of 'modify' in which the new state is generated by a+-- monadic action.+modifyM :: (Monad m) => (s -> m s) -> StateT s m ()+modifyM f = StateT $ \ s -> do+ s' <- f s+ return ((), s')+{-# INLINE modifyM #-} -- | Get a specific component of the state, using a projection function -- supplied.
Data/Functor/Reverse.hs view
@@ -28,6 +28,9 @@ ) where import Control.Applicative.Backwards+#if MIN_VERSION_base(4,18,0)+import Data.Foldable1 (Foldable1(foldMap1))+#endif import Data.Functor.Classes #if MIN_VERSION_base(4,12,0) import Data.Functor.Contravariant@@ -140,6 +143,12 @@ length (Reverse t) = length t #endif +#if MIN_VERSION_base(4,18,0)+-- | Fold from right to left.+instance (Foldable1 f) => Foldable1 (Reverse f) where+ foldMap1 f (Reverse t) = getDual (foldMap1 (Dual . f) t)+#endif+ -- | Traverse from right to left. instance (Traversable f) => Traversable (Reverse f) where traverse f (Reverse t) =@@ -148,7 +157,7 @@ #if MIN_VERSION_base(4,12,0) -- | Derived instance.-instance Contravariant f => Contravariant (Reverse f) where+instance (Contravariant f) => Contravariant (Reverse f) where contramap f = Reverse . contramap f . getReverse {-# INLINE contramap #-} #endif
changelog view
@@ -1,5 +1,9 @@ -*-change-log-*- +0.6.1.0 Ross Paterson <R.Paterson@city.ac.uk> Feb 2023+ * Add instances of Foldable1 (class added to base-4.18)+ * Add modifyM to StateT transformers+ 0.6.0.6 Ross Paterson <R.Paterson@city.ac.uk> Jan 2023 * Fix for GHC 8.6
transformers.cabal view
@@ -1,5 +1,5 @@ name: transformers-version: 0.6.0.6+version: 0.6.1.0 license: BSD3 license-file: LICENSE author: Andy Gill, Ross Paterson