Safe Haskell | None |
---|---|
Language | Haskell2010 |
- sequenceIdInputStream :: SequenceId -> (a -> SequenceId) -> (SequenceIdError -> IO ()) -> InputStream a -> IO (InputStream a)
- sequenceIdOutputStream :: SequenceId -> OutputStream a -> IO (OutputStream a, IO SequenceId)
Documentation
:: 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 |
|
-> IO (InputStream a) | Pass-through of the given stream |
Wrap an InputStream
and check for dropped or duplicated sequence IDs.
Example:
ghci>fromList
[1..10 ::SequenceId
] >>=sequenceIdInputStream
0id
(fail
.show
) >>=toList
[1,2,3,4,5,6,7,8,9,10] ghci>fromList
[5..10 ::SequenceId
] >>=sequenceIdInputStream
0id
(fail
.show
) >>=toList
*** Exception: user error (SequenceIdError
{errType =SequenceIdDropped
, lastSeqId = 0, currSeqId = 5}) ghci>fromList
[1..10 ::SequenceId
] >>=sequenceIdInputStream
5id
(fail
.show
) >>=toList
*** Exception: user error (SequenceIdError
{errType =SequenceIdDuplicated
, lastSeqId = 5, currSeqId = 1})
:: SequenceId | Initial sequence ID |
-> OutputStream a |
|
-> IO (OutputStream a, IO SequenceId) | ( |
Wrap an OutputStream
to give a sequence ID for each element written.
Example:
(outStream', getSeqId) <-sequenceIdOutputStream
1 outStream return $contramapM
(addSeqId getSeqId) outStream'