seqid-streams 0.6.0 → 0.6.1
raw patch · 2 files changed
+10/−10 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
seqid-streams.cabal view
@@ -1,5 +1,5 @@ name: seqid-streams-version: 0.6.0+version: 0.6.1 synopsis: Sequence ID IO-Streams description: Uniquely identify elements in a sequenced stream License: BSD3
src/System/IO/Streams/SequenceId.hs view
@@ -58,7 +58,8 @@ -> OutputStream b -- ^ 'System.IO.Streams.OutputStream' to count the elements of -> IO (OutputStream a) -- ^ ('IO' 'SequenceId') is the action to run to get the current sequence ID sequenceIdOutputStream i f = outputFoldM f' i- where f' seqId bdy = (seqId, f (incrementSeqId seqId) bdy)+ where f' seqId bdy = (nextSeqId, f nextSeqId bdy)+ where nextSeqId = incrementSeqId seqId outputFoldM@@ -66,14 +67,13 @@ -> a -- ^ initial seed -> OutputStream c -- ^ output stream -> IO (OutputStream b) -- ^ returns a new stream as well as an IO action to fetch the updated seed value.-outputFoldM f initial stream = do- ref <- newIORef initial+outputFoldM step initSeqId outStream = do+ ref <- newIORef initSeqId Streams.makeOutputStream (wr ref)- where- wr _ Nothing = Streams.write Nothing stream+ wr _ Nothing = Streams.write Nothing outStream wr ref (Just x) = do- !z <- readIORef ref- let (!z', !x') = f z x- writeIORef ref z'- Streams.write (Just x') stream+ !accum <- readIORef ref+ let (!accum', !x') = step accum x+ writeIORef ref accum'+ Streams.write (Just x') outStream