diff options
author | MichaelSnoyman <> | 2017-05-19 16:38:00 (GMT) |
---|---|---|
committer | hdiff <hdiff@hdiff.luite.com> | 2017-05-19 16:38:00 (GMT) |
commit | 37326b2229d5c99810b15f3a46ca54ad60f6a5d4 (patch) | |
tree | a9b9952f69182ef8315ab9a5ca45cd4c87607869 | |
parent | 9292af79472e987cdea7801e20c72d55c7aeeaf1 (diff) |
version 1.1.161.1.16
-rw-r--r-- | ChangeLog.md | 5 | ||||
-rw-r--r-- | Data/Conduit/Foldl.hs | 26 | ||||
-rwxr-xr-x[-rw-r--r--] | Setup.lhs | 0 | ||||
-rw-r--r-- | conduit-extra.cabal | 3 |
4 files changed, 33 insertions, 1 deletions
diff --git a/ChangeLog.md b/ChangeLog.md index bd83ccf..61df17b 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,8 @@ +## 1.1.16 + +* Add `Data.Conduit.Foldl` adapter module for the `foldl` + package. [#312](https://github.com/snoyberg/conduit/pull/312) + ## 1.1.15 * `sinkTempFile` and `sinkSystemTempFile` diff --git a/Data/Conduit/Foldl.hs b/Data/Conduit/Foldl.hs new file mode 100644 index 0000000..300e4ab --- /dev/null +++ b/Data/Conduit/Foldl.hs @@ -0,0 +1,26 @@ +{-# LANGUAGE RankNTypes #-} +-- | Adapter module to work with the <https://hackage.haskell.org/package/foldl foldl> package. +-- +-- @since 1.1.16 +module Data.Conduit.Foldl where + +import Data.Conduit +import Control.Monad.Trans.Class (lift) +import qualified Data.Conduit.List as CL + +-- | Convert a left fold into a 'Consumer'. This function is intended +-- to be used with @purely@ from the +-- <https://hackage.haskell.org/package/foldl foldl> package. +-- +-- @since 1.1.16 +sinkFold :: Monad m => (x -> a -> x) -> x -> (x -> b) -> Consumer a m b +sinkFold combine seed extract = fmap extract (CL.fold combine seed) + +-- | Convert a monadic left fold into a 'Consumer'. This function is +-- intended to be used with @impurely@ from the +-- <https://hackage.haskell.org/package/foldl foldl> package. +-- +-- @since 1.1.16 +sinkFoldM :: Monad m => (x -> a -> m x) -> m x -> (x -> m b) -> Consumer a m b +sinkFoldM combine seed extract = + lift . extract =<< CL.foldM combine =<< lift seed diff --git a/Setup.lhs b/Setup.lhs index 06e2708..06e2708 100644..100755 --- a/Setup.lhs +++ b/Setup.lhs diff --git a/conduit-extra.cabal b/conduit-extra.cabal index 0b86619..63082c1 100644 --- a/conduit-extra.cabal +++ b/conduit-extra.cabal @@ -1,5 +1,5 @@ Name: conduit-extra -Version: 1.1.15 +Version: 1.1.16 Synopsis: Batteries included conduit: adapters for common libraries. Description: The conduit package itself maintains relative small dependencies. The purpose of this package is to collect commonly used utility functions wrapping other library dependencies, without depending on heavier-weight dependencies. The basic idea is that this package should only depend on haskell-platform packages and conduit. @@ -24,6 +24,7 @@ Library Data.Conduit.Blaze Data.Conduit.ByteString.Builder Data.Conduit.Filesystem + Data.Conduit.Foldl Data.Conduit.Lazy Data.Conduit.Network Data.Conduit.Network.UDP |