seqid-streams 0.6.3 → 0.7.0
raw patch · 2 files changed
+18/−19 lines, 2 filesdep ~seqidnew-uploaderPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: seqid
API changes (from Hackage documentation)
- System.IO.Streams.SequenceId: sequenceIdInputStream :: SequenceId -> (a -> SequenceId) -> (SequenceIdError -> IO ()) -> InputStream a -> IO (InputStream a)
+ System.IO.Streams.SequenceId: sequenceIdInputStream :: Integral s => s -> (a -> s) -> (SequenceIdError s -> IO ()) -> InputStream a -> IO (InputStream a)
- System.IO.Streams.SequenceId: sequenceIdOutputStream :: SequenceId -> (SequenceId -> a -> b) -> OutputStream b -> IO (OutputStream a)
+ System.IO.Streams.SequenceId: sequenceIdOutputStream :: Integral s => s -> (s -> a -> b) -> OutputStream b -> IO (OutputStream a)
Files
- seqid-streams.cabal +2/−2
- src/System/IO/Streams/SequenceId.hs +16/−17
seqid-streams.cabal view
@@ -1,5 +1,5 @@ name: seqid-streams-version: 0.6.3+version: 0.7.0 synopsis: Sequence ID IO-Streams description: Uniquely identify elements in a sequenced stream License: BSD3@@ -22,7 +22,7 @@ build-depends: base >= 4.7 && < 4.12 , io-streams >= 1.2 && < 1.6- , seqid >= 0.4 && < 0.6+ , seqid >= 0.6 && < 0.7 hs-source-dirs: src default-language: Haskell2010
src/System/IO/Streams/SequenceId.hs view
@@ -7,7 +7,7 @@ import Control.Applicative ((<$>)) import Data.IORef (newIORef, readIORef, writeIORef)-import Data.SequenceId (SequenceId, SequenceIdError, checkSeqId,+import Data.SequenceId (SequenceIdError, checkSeqId, incrementSeqId) import System.IO.Streams (InputStream, OutputStream) import qualified System.IO.Streams as Streams@@ -28,12 +28,12 @@ -- ghci> 'System.IO.Streams.fromList' [1..10 :: 'Data.SequenceId.SequenceId'] >>= 'sequenceIdInputStream' 5 'id' ('fail' . 'show') >>= 'System.IO.Streams.toList' -- *** Exception: user error ('Data.SequenceId.SequenceIdError' {errType = 'Data.SequenceId.SequenceIdDuplicated', lastSeqId = 5, currSeqId = 1}) -- @-sequenceIdInputStream- :: SequenceId -- ^ Initial sequence ID- -> (a -> SequenceId) -- ^ Function applied to each element of the stream to get the sequence ID- -> (SequenceIdError -> IO ()) -- ^ Error handler- -> InputStream a -- ^ 'System.IO.Streams.InputStream' to check the sequence of- -> IO (InputStream a) -- ^ Pass-through of the given stream+sequenceIdInputStream :: Integral s+ => s -- ^ Initial sequence ID+ -> (a -> s) -- ^ Function applied to each element of the stream to get the sequence ID+ -> (SequenceIdError s -> IO ()) -- ^ Error handler+ -> InputStream a -- ^ 'System.IO.Streams.InputStream' to check the sequence of+ -> IO (InputStream a) -- ^ Pass-through of the given stream sequenceIdInputStream initSeqId getSeqId seqIdFaultHandler inStream = fst <$> Streams.inputFoldM f initSeqId inStream where@@ -52,21 +52,20 @@ -- (outStream', getSeqId) <- 'sequenceIdOutputStream' 1 outStream -- return $ 'System.IO.Streams.Combinators.contramapM' (addSeqId getSeqId) outStream' -- @-sequenceIdOutputStream- :: SequenceId -- ^ Initial sequence ID- -> (SequenceId -> a -> b) -- ^ Transformation function- -> 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 :: Integral s+ => s -- ^ Initial sequence ID+ -> (s -> a -> b) -- ^ Transformation function+ -> 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 = (nextSeqId, f nextSeqId bdy) where nextSeqId = incrementSeqId seqId -outputFoldM- :: (a -> b -> (a, c)) -- ^ fold function- -> 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 :: (a -> b -> (a, c)) -- ^ fold function+ -> 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 step initSeqId outStream = do ref <- newIORef initSeqId Streams.makeOutputStream (wr ref)