potoki 0.11 → 0.11.1
raw patch · 2 files changed
+15/−2 lines, 2 files
Files
- library/Potoki/Consume.hs +14/−1
- potoki.cabal +1/−1
library/Potoki/Consume.hs view
@@ -5,11 +5,13 @@ count, sum, head,+ last, list, reverseList, vector, concat, fold,+ execState, foldInIO, writeBytesToFile, appendBytesToFile,@@ -23,7 +25,7 @@ ) where -import Potoki.Prelude hiding (sum, head, fold, concat)+import Potoki.Prelude hiding (sum, head, fold, concat, last) import Potoki.Core.Consume import qualified Potoki.Core.Fetch as A import qualified Potoki.Core.Produce as H@@ -37,6 +39,7 @@ import qualified Control.Foldl as D import qualified System.Directory as G import qualified Potoki.Transform.Concurrency as B+import qualified Control.Monad.Trans.State.Strict as O {-# INLINABLE head #-}@@ -44,6 +47,11 @@ head = Consume (\ (A.Fetch fetchIO) -> fetchIO Nothing Just) +{-# INLINABLE last #-}+last :: Consume input (Maybe input)+last = + fold D.last + {-| A faster alternative to "list", which however constructs the list in the reverse order.@@ -140,6 +148,11 @@ where build fetch !accumulator = join (fetch (pure (finish accumulator)) (\ !input -> build fetch (step accumulator input)))++{-# INLINE execState #-}+execState :: (a -> O.State s b) -> s -> Consume a s+execState stateFn initialState = + fold $ D.Fold (\currentState input -> snd $ O.runState (stateFn input) currentState) initialState id {-# INLINABLE foldInIO #-} foldInIO :: D.FoldM IO input output -> Consume input output
potoki.cabal view
@@ -1,7 +1,7 @@ name: potoki version:- 0.11+ 0.11.1 synopsis: Simple streaming in IO description: