constrictor 0.1.0.2 → 0.1.1.0
raw patch · 3 files changed
+275/−211 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Control.Monad.Constrictor: (<$!>) :: Monad m => (a -> b) -> m a -> m b
- Control.Monad.Constrictor: Ap :: f a -> Ap f a
- Control.Monad.Constrictor: [getAp] :: Ap f a -> f a
- Control.Monad.Constrictor: ap' :: Monad m => m (a -> b) -> m a -> m b
- Control.Monad.Constrictor: fmap' :: Monad m => (a -> b) -> m a -> m b
- Control.Monad.Constrictor: foldlMapA :: forall t b a f. (Foldable t, Monoid b, Applicative f) => (a -> f b) -> t a -> f b
- Control.Monad.Constrictor: foldlMapM' :: forall t b a m. (Foldable t, Monoid b, Monad m) => (a -> m b) -> t a -> m b
- Control.Monad.Constrictor: foldrMapA :: forall t b a f. (Foldable t, Monoid b, Applicative f) => (a -> f b) -> t a -> f b
- Control.Monad.Constrictor: foldrMapM' :: forall t b a m. (Foldable t, Monoid b, Monad m) => (a -> m b) -> t a -> m b
- Control.Monad.Constrictor: infixl 4 `liftM4'`
- Control.Monad.Constrictor: instance (GHC.Base.Applicative f, Data.Semigroup.Semigroup a) => Data.Semigroup.Semigroup (Control.Monad.Constrictor.Ap f a)
- Control.Monad.Constrictor: instance (GHC.Base.Applicative f, GHC.Base.Monoid a) => GHC.Base.Monoid (Control.Monad.Constrictor.Ap f a)
- Control.Monad.Constrictor: instance Control.Monad.Fail.MonadFail f => Control.Monad.Fail.MonadFail (Control.Monad.Constrictor.Ap f)
- Control.Monad.Constrictor: instance Control.Monad.Fix.MonadFix f => Control.Monad.Fix.MonadFix (Control.Monad.Constrictor.Ap f)
- Control.Monad.Constrictor: instance Data.Foldable.Foldable f => Data.Foldable.Foldable (Control.Monad.Constrictor.Ap f)
- Control.Monad.Constrictor: instance Data.Traversable.Traversable f => Data.Traversable.Traversable (Control.Monad.Constrictor.Ap f)
- Control.Monad.Constrictor: instance GHC.Base.Alternative f => GHC.Base.Alternative (Control.Monad.Constrictor.Ap f)
- Control.Monad.Constrictor: instance GHC.Base.Applicative f => GHC.Base.Applicative (Control.Monad.Constrictor.Ap f)
- Control.Monad.Constrictor: instance GHC.Base.Functor f => GHC.Base.Functor (Control.Monad.Constrictor.Ap f)
- Control.Monad.Constrictor: instance GHC.Base.Monad f => GHC.Base.Monad (Control.Monad.Constrictor.Ap f)
- Control.Monad.Constrictor: instance GHC.Base.MonadPlus f => GHC.Base.MonadPlus (Control.Monad.Constrictor.Ap f)
- Control.Monad.Constrictor: instance GHC.Classes.Eq (f a) => GHC.Classes.Eq (Control.Monad.Constrictor.Ap f a)
- Control.Monad.Constrictor: instance GHC.Classes.Ord (f a) => GHC.Classes.Ord (Control.Monad.Constrictor.Ap f a)
- Control.Monad.Constrictor: instance GHC.Enum.Enum (f a) => GHC.Enum.Enum (Control.Monad.Constrictor.Ap f a)
- Control.Monad.Constrictor: instance GHC.Generics.Generic (Control.Monad.Constrictor.Ap f a)
- Control.Monad.Constrictor: instance GHC.Generics.Generic1 (Control.Monad.Constrictor.Ap f)
- Control.Monad.Constrictor: instance GHC.Num.Num (f a) => GHC.Num.Num (Control.Monad.Constrictor.Ap f a)
- Control.Monad.Constrictor: instance GHC.Read.Read (f a) => GHC.Read.Read (Control.Monad.Constrictor.Ap f a)
- Control.Monad.Constrictor: instance GHC.Show.Show (f a) => GHC.Show.Show (Control.Monad.Constrictor.Ap f a)
- Control.Monad.Constrictor: liftM' :: Monad m => (a -> b) -> m a -> m b
- Control.Monad.Constrictor: liftM2' :: Monad m => (a -> b -> c) -> m a -> m b -> m c
- Control.Monad.Constrictor: liftM3' :: Monad m => (a -> b -> c -> d) -> m a -> m b -> m c -> m d
- Control.Monad.Constrictor: liftM4' :: Monad m => (a -> b -> c -> d -> e) -> m a -> m b -> m c -> m d -> m e
- Control.Monad.Constrictor: liftM5' :: Monad m => (a -> b -> c -> d -> e -> f) -> m a -> m b -> m c -> m d -> m e -> m f
- Control.Monad.Constrictor: mapM' :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b)
- Control.Monad.Constrictor: newtype Ap f a
- Control.Monad.Constrictor: traverse' :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)
+ Constrictor: (<$!>) :: Monad m => (a -> b) -> m a -> m b
+ Constrictor: Ap :: f a -> Ap f a
+ Constrictor: [getAp] :: Ap f a -> f a
+ Constrictor: ap' :: Monad m => m (a -> b) -> m a -> m b
+ Constrictor: fmap' :: Monad m => (a -> b) -> m a -> m b
+ Constrictor: foldlMap :: (Monoid m, Foldable t) => (a -> m) -> t a -> m
+ Constrictor: foldlMap' :: (Monoid m, Foldable t) => (a -> m) -> t a -> m
+ Constrictor: foldlMapA :: forall t b a f. (Foldable t, Monoid b, Applicative f) => (a -> f b) -> t a -> f b
+ Constrictor: foldlMapM' :: forall t b a m. (Foldable t, Monoid b, Monad m) => (a -> m b) -> t a -> m b
+ Constrictor: foldrMap :: (Monoid m, Foldable t) => (a -> m) -> t a -> m
+ Constrictor: foldrMap' :: (Monoid m, Foldable t) => (a -> m) -> t a -> m
+ Constrictor: foldrMapA :: forall t b a f. (Foldable t, Monoid b, Applicative f) => (a -> f b) -> t a -> f b
+ Constrictor: foldrMapM' :: forall t b a m. (Foldable t, Monoid b, Monad m) => (a -> m b) -> t a -> m b
+ Constrictor: infixl 4 `liftM'`
+ Constrictor: instance (GHC.Base.Applicative f, Data.Semigroup.Semigroup a) => Data.Semigroup.Semigroup (Constrictor.Ap f a)
+ Constrictor: instance (GHC.Base.Applicative f, GHC.Base.Monoid a) => GHC.Base.Monoid (Constrictor.Ap f a)
+ Constrictor: instance Control.Monad.Fail.MonadFail f => Control.Monad.Fail.MonadFail (Constrictor.Ap f)
+ Constrictor: instance Control.Monad.Fix.MonadFix f => Control.Monad.Fix.MonadFix (Constrictor.Ap f)
+ Constrictor: instance Data.Foldable.Foldable f => Data.Foldable.Foldable (Constrictor.Ap f)
+ Constrictor: instance Data.Traversable.Traversable f => Data.Traversable.Traversable (Constrictor.Ap f)
+ Constrictor: instance GHC.Base.Alternative f => GHC.Base.Alternative (Constrictor.Ap f)
+ Constrictor: instance GHC.Base.Applicative f => GHC.Base.Applicative (Constrictor.Ap f)
+ Constrictor: instance GHC.Base.Functor f => GHC.Base.Functor (Constrictor.Ap f)
+ Constrictor: instance GHC.Base.Monad f => GHC.Base.Monad (Constrictor.Ap f)
+ Constrictor: instance GHC.Base.MonadPlus f => GHC.Base.MonadPlus (Constrictor.Ap f)
+ Constrictor: instance GHC.Classes.Eq (f a) => GHC.Classes.Eq (Constrictor.Ap f a)
+ Constrictor: instance GHC.Classes.Ord (f a) => GHC.Classes.Ord (Constrictor.Ap f a)
+ Constrictor: instance GHC.Enum.Enum (f a) => GHC.Enum.Enum (Constrictor.Ap f a)
+ Constrictor: instance GHC.Generics.Generic (Constrictor.Ap f a)
+ Constrictor: instance GHC.Generics.Generic1 (Constrictor.Ap f)
+ Constrictor: instance GHC.Num.Num (f a) => GHC.Num.Num (Constrictor.Ap f a)
+ Constrictor: instance GHC.Read.Read (f a) => GHC.Read.Read (Constrictor.Ap f a)
+ Constrictor: instance GHC.Show.Show (f a) => GHC.Show.Show (Constrictor.Ap f a)
+ Constrictor: liftM' :: Monad m => (a -> b) -> m a -> m b
+ Constrictor: liftM2' :: Monad m => (a -> b -> c) -> m a -> m b -> m c
+ Constrictor: liftM3' :: Monad m => (a -> b -> c -> d) -> m a -> m b -> m c -> m d
+ Constrictor: liftM4' :: Monad m => (a -> b -> c -> d -> e) -> m a -> m b -> m c -> m d -> m e
+ Constrictor: liftM5' :: Monad m => (a -> b -> c -> d -> e -> f) -> m a -> m b -> m c -> m d -> m e -> m f
+ Constrictor: mapM' :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b)
+ Constrictor: newtype Ap f a
+ Constrictor: traverse' :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)
Files
- Control/Monad/Constrictor.hs +0/−191
- constrictor.cabal +38/−20
- src/Constrictor.hs +237/−0
− Control/Monad/Constrictor.hs
@@ -1,191 +0,0 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE DeriveFoldable #-}-{-# LANGUAGE DeriveFunctor #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE DeriveTraversable #-}-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE ScopedTypeVariables #-}--{-|-This library provides strict versions of many-functions in base, as well as a few functions-that do not have lazy versions that exist in-base (see the section on Folds).--}--module Control.Monad.Constrictor- ( - -- * Strict monadic functions - (<$!>)- , fmap'- , liftM'- , liftM2'- , liftM3'- , liftM4'- , liftM5'- , ap' - , mapM'- - -- * Strict applicative functions- , traverse'-- -- * Folds- -- ** Stict monadic folds- , foldlMapM'- , foldrMapM'- -- ** Lazy applicative folds- , foldlMapA- , foldrMapA- -- * Types- -- ** Wrapped applicative functor- , Ap(..)- ) where--import Control.Applicative-import Control.Monad (MonadPlus)-import Control.Monad.Fail (MonadFail)-import Control.Monad.Fix (MonadFix)-import Control.Monad.Trans.Cont (evalCont, cont)-import Data.Foldable-import Data.Functor.Compose (Compose(..))-import Data.Monoid hiding ((<>))-import Data.Semigroup-import Data.Traversable (traverse)-import GHC.Generics (Generic,Generic1)---- | A wrapped applicative functor.-newtype Ap f a = Ap { getAp :: f a }- deriving ( Alternative, Applicative- , Enum, Eq, Foldable, Functor- , Generic, Generic1- , Monad, MonadFail, MonadFix, MonadPlus- , Num, Ord, Read, Show, Traversable- )--instance (Applicative f, Semigroup a) => Semigroup (Ap f a) where- (Ap x) <> (Ap y) = Ap $ liftA2 (<>) x y--instance (Applicative f, Monoid a) => Monoid (Ap f a) where- mempty = Ap $ pure mempty-#if !(MIN_VERSION_base(4,11,0))- mappend (Ap x) (Ap y) = Ap $ liftA2 (mappend) x y-#endif---- | Lazy in the monoidal accumulator. Monoidal accumulation--- happens from left to right.-foldlMapA :: forall t b a f. (Foldable t, Monoid b, Applicative f) => (a -> f b) -> t a -> f b-foldlMapA f = foldr f' (pure mempty)- where- f' :: a -> f b -> f b- f' x y = liftA2 mappend (f x) y---- | Lazy in the monoidal accumulator. Monoidal accumulation--- happens from left to right.-foldrMapA :: forall t b a f. (Foldable t, Monoid b, Applicative f) => (a -> f b) -> t a -> f b-foldrMapA f = foldl f' (pure mempty)- where- f' :: f b -> a -> f b- f' y x = liftA2 (flip mappend) (f x) y---- | Strict in the monoidal accumulator.--- For monads strict in the left argument of bind,--- this will run in constant space.--- Monoidal accumulation happens from left to right.-foldlMapM' :: forall t b a m. (Foldable t, Monoid b, Monad m) => (a -> m b) -> t a -> m b-foldlMapM' f xs = foldr f' pure xs mempty- where- f' :: a -> (b -> m b) -> b -> m b- f' x k bl = do- br <- f x- k $! (mappend bl br) ---- Strict in the monoidal accumulator. --- Monoidal accumulation happens from left to right.-foldrMapM' :: forall t b a m. (Foldable t, Monoid b, Monad m) => (a -> m b) -> t a -> m b-foldrMapM' f xs = foldl f' pure xs mempty- where- f' :: (b -> m b) -> a -> b -> m b- f' k x br = do- bl <- f x- k $! (mappend bl br) --infixl 4 <$!>, `fmap'`, `liftM4'`---- | Strict version of 'Data.Functor.<$>'-(<$!>) :: Monad m => (a -> b) -> m a -> m b-{-# INLINE (<$!>) #-}-f <$!> m = do- x <- m- pure $! f x---- Note this is equivalent to '<$!>',--- and is provided for convenience.-fmap' :: Monad m => (a -> b) -> m a -> m b-{-# INLINE fmap' #-}-fmap' = (<$!>)---- | Strict version of 'Control.Monad.liftM'.------ Note this is equivalent to '<$!>',--- and is provided for convenience.-liftM' :: Monad m => (a -> b) -> m a -> m b-{-# INLINE liftM' #-} -liftM' = (<$!>)---- | Strict version of 'Control.Monad.liftM2'.-liftM2' :: Monad m => (a -> b -> c) -> m a -> m b -> m c-{-# INLINE liftM2' #-}-liftM2' f a b = do- x <- a- y <- b- pure $! f x y---- | Strict version of 'Control.Monad.liftM3'.-liftM3' :: Monad m => (a -> b -> c -> d) -> m a -> m b -> m c -> m d-{-# INLINE liftM3' #-}-liftM3' f a b c = do- x <- a- y <- b- z <- c- pure $! f x y z---- | Strict version of 'Control.Monad.liftM4'.-liftM4' :: Monad m => (a -> b -> c -> d -> e) -> m a -> m b -> m c -> m d -> m e -{-# INLINE liftM4' #-}-liftM4' f a b c d = do- x <- a- y <- b- z <- c- u <- d- pure $! f x y z u---- | Strict version of 'Control.Monad.liftM5'.-liftM5' :: Monad m => (a -> b -> c -> d -> e -> f) -> m a -> m b -> m c -> m d -> m e -> m f-{-# INLINE liftM5' #-}-liftM5' f a b c d e = do- x <- a- y <- b- z <- c- u <- d- v <- e- pure $! f x y z u v---- | Strict version of 'Control.Monad.ap'-ap' :: Monad m => m (a -> b) -> m a -> m b-{-# INLINE ap' #-}-ap' m1 m2 = do- f <- m1- x <- m2- pure $! f x---- | Strict version of 'Data.Traversable.traverse'.-traverse' :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)-{-# INLINE traverse' #-}-traverse' f = fmap evalCont . getCompose . traverse (Compose . fmap (\a -> cont $ \k -> k $! a) . f)---- | Strict version of 'Control.Monad.mapM'.------ This is just 'traverse'' specialised to 'Monad'.-mapM' :: (Traversable t, Monad m) => (a -> m b) -> t a-> m (t b)-{-# INLINE mapM' #-}-mapM' = traverse'
constrictor.cabal view
@@ -1,22 +1,40 @@-name: constrictor-version: 0.1.0.2-synopsis: strict versions of many things in base-description: This package provides strict versions of many functions in- base, including some functions not present, such as- 'foldlMapA', 'foldlMapM', 'foldrMapA', and foldrMapM.-homepage: https://github.com/chessai/constrictor.git-license: MIT-license-file: LICENSE-author: chessai-maintainer: chessai1996@gmail.com-copyright: 2018 (c) chessai -category: Control-build-type: Simple-extra-source-files: ChangeLog.md-cabal-version: >=1.10+name:+ constrictor+version:+ 0.1.1.0+synopsis:+ strict versions of many things in base+description:+ This package provides strict versions of many functions in+ base, including many folding functions not present in there.+homepage:+ https://github.com/chessai/constrictor.git+license:+ MIT+license-file:+ LICENSE+author:+ chessai+maintainer:+ chessai1996@gmail.com+copyright:+ 2018 (c) chessai +category:+ Control+build-type:+ Simple+extra-source-files:+ ChangeLog.md+cabal-version:+ >=1.10 library- exposed-modules: Control.Monad.Constrictor - build-depends: base >=4.7 && < 5.0- , transformers - default-language: Haskell2010+ hs-source-dirs:+ src + exposed-modules:+ Constrictor + build-depends:+ base >=4.7 && < 5.0+ , transformers + default-language:+ Haskell2010
+ src/Constrictor.hs view
@@ -0,0 +1,237 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE DeriveFoldable #-}+{-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE DeriveTraversable #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE ScopedTypeVariables #-}++{-|+This library provides strict versions of many+functions in base, as well as a few functions+that do not have lazy versions that exist in+base (see the section on Folds).+-}++module Constrictor+ ( + -- * Strict monadic functions + (<$!>)+ , fmap'+ , liftM'+ , liftM2'+ , liftM3'+ , liftM4'+ , liftM5'+ , ap' + + -- * Strict traversable functions+ , traverse'+ , mapM'+ + -- * Folds+ -- ** Lazy monoidal folds+ , foldrMap+ , foldlMap+ -- ** Strict monoidal folds+ , foldrMap'+ , foldlMap'+ -- ** Lazy applicative folds+ , foldlMapA+ , foldrMapA+ -- ** Strict monadic folds+ , foldlMapM'+ , foldrMapM'+ -- * Types+ -- ** Wrapped applicative functor+ , Ap(..)+ ) where++import Control.Applicative+import Control.Monad (MonadPlus)+import Control.Monad.Fail (MonadFail)+import Control.Monad.Fix (MonadFix)+import Control.Monad.Trans.Cont (evalCont, cont)+import Data.Foldable+import Data.Functor.Compose (Compose(..))+import Data.Monoid hiding ((<>))+import Data.Semigroup+import Data.Traversable (traverse)+import GHC.Generics (Generic,Generic1)++-- | A wrapped applicative functor.+-- Please note that base 4.12.0.0 will include this type,+-- and it will be removed from this library at that point.+newtype Ap f a = Ap { getAp :: f a }+ deriving ( Alternative, Applicative+ , Enum, Eq, Foldable, Functor+ , Generic, Generic1+ , Monad, MonadFail, MonadFix, MonadPlus+ , Num, Ord, Read, Show, Traversable+ )++instance (Applicative f, Semigroup a) => Semigroup (Ap f a) where+ (Ap x) <> (Ap y) = Ap $ liftA2 (<>) x y++instance (Applicative f, Monoid a) => Monoid (Ap f a) where+ mempty = Ap $ pure mempty+#if !(MIN_VERSION_base(4,11,0))+ mappend (Ap x) (Ap y) = Ap $ liftA2 (mappend) x y+#endif++-- | Lazy in the monoidal accumulator. Monoidal accumulation+-- happens from left to right.+foldlMapA :: forall t b a f. (Foldable t, Monoid b, Applicative f) => (a -> f b) -> t a -> f b+foldlMapA f = foldr f' (pure mempty)+ where+ f' :: a -> f b -> f b+ f' x y = liftA2 mappend (f x) y++-- | Lazy in the monoidal accumulator. Monoidal accumulation+-- happens from left to right.+foldrMapA :: forall t b a f. (Foldable t, Monoid b, Applicative f) => (a -> f b) -> t a -> f b+foldrMapA f = foldl f' (pure mempty)+ where+ f' :: f b -> a -> f b+ f' y x = liftA2 (flip mappend) (f x) y++-- | Strict in the monoidal accumulator.+-- For monads strict in the left argument of bind,+-- this will run in constant space.+-- Monoidal accumulation happens from left to right.+foldlMapM' :: forall t b a m. (Foldable t, Monoid b, Monad m) => (a -> m b) -> t a -> m b+foldlMapM' f xs = foldr f' pure xs mempty+ where+ f' :: a -> (b -> m b) -> b -> m b+ f' x k bl = do+ br <- f x+ k $! (mappend bl br) ++-- Strict in the monoidal accumulator. +-- Monoidal accumulation happens from left to right.+foldrMapM' :: forall t b a m. (Foldable t, Monoid b, Monad m) => (a -> m b) -> t a -> m b+foldrMapM' f xs = foldl f' pure xs mempty+ where+ f' :: (b -> m b) -> a -> b -> m b+ f' k x br = do+ bl <- f x+ k $! (mappend bl br) ++infixl 4 <$!>, `fmap'`, `liftM'`++-- | Strict version of 'Data.Functor.<$>'+(<$!>) :: Monad m => (a -> b) -> m a -> m b+{-# INLINE (<$!>) #-}+f <$!> m = do+ x <- m+ pure $! f x++-- Note this is equivalent to '<$!>',+-- and is provided for convenience.+fmap' :: Monad m => (a -> b) -> m a -> m b+{-# INLINE fmap' #-}+fmap' = (<$!>)++-- | Strict version of 'Control.Monad.liftM'.+--+-- Note this is equivalent to '<$!>',+-- and is provided for convenience.+liftM' :: Monad m => (a -> b) -> m a -> m b+{-# INLINE liftM' #-} +liftM' = (<$!>)++-- | Strict version of 'Control.Monad.liftM2'.+liftM2' :: Monad m => (a -> b -> c) -> m a -> m b -> m c+{-# INLINE liftM2' #-}+liftM2' f a b = do+ x <- a+ y <- b+ pure $! f x y++-- | Strict version of 'Control.Monad.liftM3'.+liftM3' :: Monad m => (a -> b -> c -> d) -> m a -> m b -> m c -> m d+{-# INLINE liftM3' #-}+liftM3' f a b c = do+ x <- a+ y <- b+ z <- c+ pure $! f x y z++-- | Strict version of 'Control.Monad.liftM4'.+liftM4' :: Monad m => (a -> b -> c -> d -> e) -> m a -> m b -> m c -> m d -> m e +{-# INLINE liftM4' #-}+liftM4' f a b c d = do+ x <- a+ y <- b+ z <- c+ u <- d+ pure $! f x y z u++-- | Strict version of 'Control.Monad.liftM5'.+liftM5' :: Monad m => (a -> b -> c -> d -> e -> f) -> m a -> m b -> m c -> m d -> m e -> m f+{-# INLINE liftM5' #-}+liftM5' f a b c d e = do+ x <- a+ y <- b+ z <- c+ u <- d+ v <- e+ pure $! f x y z u v++-- | Strict version of 'Control.Monad.ap'+ap' :: Monad m => m (a -> b) -> m a -> m b+{-# INLINE ap' #-}+ap' m1 m2 = do+ f <- m1+ x <- m2+ pure $! f x++-- | Strict version of 'Data.Traversable.traverse'.+traverse' :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)+{-# INLINE traverse' #-}+traverse' f = fmap evalCont . getCompose . traverse (Compose . fmap (\a -> cont $ \k -> k $! a) . f)++-- | Strict version of 'Control.Monad.mapM'.+--+-- This is just 'traverse'' specialised to 'Monad'.+mapM' :: (Traversable t, Monad m) => (a -> m b) -> t a-> m (t b)+{-# INLINE mapM' #-}+mapM' = traverse'++-- The INLINES used below allow more list functions to fuse.+-- See Trac #9848.+{-# INLINE foldrMap #-}+{-# INLINE foldrMap' #-}+{-# INLINE foldlMap #-}+{-# INLINE foldlMap' #-}++-- | Map each element of a foldable structure to a monoid,+-- and combine the results. This function is left-associative.+--+-- The operator is applied lazily. For a strict version, see+-- 'foldlMap''.+foldlMap :: (Monoid m, Foldable t) => (a -> m) -> t a -> m+foldlMap f = foldl (flip (mappend . f)) mempty++-- | Map each element of a foldable structure to a monoid,+-- and combine the results. This function is right-associative.+--+-- Note that this is equivalent to 'Data.Foldable.foldMap'.+foldrMap :: (Monoid m, Foldable t) => (a -> m) -> t a -> m+foldrMap f = foldr (mappend . f) mempty++-- | Map each element of a foldable structure to a monoid,+-- and combine the results. This function is left-associative.+--+-- The operator is applied strictly. For a lazy version, see+-- 'foldlMap'.+foldlMap' :: (Monoid m, Foldable t) => (a -> m) -> t a -> m+foldlMap' f = foldl' (flip (mappend . f)) mempty ++-- | Map each element of a foldable structure to a monoid,+-- and combine the results. This function is right-associative.+--+-- Note that this is equivalent to 'Data.Foldable.foldMap',+-- but is strict.+foldrMap' :: (Monoid m, Foldable t) => (a -> m) -> t a -> m+foldrMap' f = foldr' (mappend . f) mempty