list-transformer 1.0.8 → 1.0.9
raw patch · 2 files changed
+12/−2 lines, 2 filesdep +mmorphdep ~mtlPVP ok
version bump matches the API change (PVP)
Dependencies added: mmorph
Dependency ranges changed: mtl
API changes (from Hackage documentation)
+ List.Transformer: class MFunctor (t :: Type -> Type -> k -> Type)
+ List.Transformer: hoist :: forall m n (b :: k). (MFunctor t, Monad m) => (forall a. () => m a -> n a) -> t m b -> t n b
+ List.Transformer: instance Control.Monad.Morph.MFunctor List.Transformer.ListT
+ List.Transformer: instance Control.Monad.Morph.MFunctor List.Transformer.Step
Files
- list-transformer.cabal +2/−1
- src/List/Transformer.hs +10/−1
list-transformer.cabal view
@@ -1,5 +1,5 @@ name: list-transformer-version: 1.0.8+version: 1.0.9 synopsis: List monad transformer description: This library provides a list monad transformer that enriches lists with effects and streams efficiently in@@ -24,6 +24,7 @@ default-language: Haskell2010 build-depends: base >= 4.5 && < 5 , mtl >= 2.1 && < 2.3+ , mmorph >= 1.1.3 && < 1.3 if !impl(ghc >= 8.0) build-depends: semigroups == 0.18.* if !impl(ghc >= 8.0)
src/List/Transformer.hs view
@@ -67,6 +67,7 @@ , MonadTrans(..) , MonadIO(..) , Alternative(..)+ , MFunctor (..) ) where #if MIN_VERSION_base(4,8,0)@@ -83,6 +84,7 @@ #if MIN_VERSION_base(4,9,0) && !(MIN_VERSION_base(4,13,0)) import Control.Monad.Fail (MonadFail(..)) #endif+import Control.Monad.Morph (MFunctor (..)) import Control.Monad.State.Class (MonadState(..)) import Control.Monad.Reader.Class (MonadReader(..)) import Control.Monad.Trans (MonadTrans(..), MonadIO(..))@@ -370,6 +372,9 @@ state k = lift (state k) +instance MFunctor ListT where+ hoist f xs = ListT (f (fmap (hoist f) (next xs)))+ instance (Monad m, Num a) => Num (ListT m a) where fromInteger n = pure (fromInteger n) @@ -652,7 +657,7 @@ {- $repetition Unbounded repetition can be induced using @'select' ('Data.List.repeat' ())@.-For example, here are four functions analogous to 'Data.List.cycle':+For example, here are several functions analogous to 'Data.List.cycle': > cycle1 :: Monad m => a -> ListT m a > cycle1 a = do@@ -774,6 +779,10 @@ instance Monad m => Functor (Step m) where fmap _ Nil = Nil fmap k (Cons x l) = Cons (k x) (fmap k l)++instance MFunctor Step where+ hoist _ Nil = Nil+ hoist f (Cons x xs) = Cons x (hoist f xs) -- | Similar to 'ZipList' in /base/: a newtype wrapper over 'ListT' that -- overrides its normal 'Applicative' instance (combine every combination)