potoki 0.10.4 → 0.10.5
raw patch · 2 files changed
+15/−1 lines, 2 files
Files
- library/Potoki/Transform.hs +14/−0
- potoki.cabal +1/−1
library/Potoki/Transform.hs view
@@ -8,6 +8,7 @@ ioTransform, take, takeWhile,+ drop, mapFilter, filter, just,@@ -75,6 +76,19 @@ takeWhile :: (input -> Bool) -> Transform input input takeWhile predicate = Transform (pure . A.takeWhile predicate)++{-# INLINE drop #-}+drop :: Int -> Transform input input+drop amount =+ Transform $ \ (A.Fetch fetchIO) -> do+ countRef <- newIORef amount+ return $ A.Fetch $ \ nil just -> fix $ \ loop -> do+ count <- readIORef countRef+ if count > 0+ then do+ writeIORef countRef $! pred count+ loop+ else fetchIO nil just {-# INLINE mapWithParseResult #-} mapWithParseResult :: forall input parsed. (Monoid input, Eq input) => (input -> M.IResult input parsed) -> Transform input (Either Text parsed)
potoki.cabal view
@@ -1,7 +1,7 @@ name: potoki version:- 0.10.4+ 0.10.5 synopsis: Simple streaming in IO description: