Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Decoder a
- = Consume (ByteString -> Decoder a)
- | Produce !a (Decoder a)
- | Done ByteString
- | Error ByteString String
- decodeHeader :: Decoder Header
- decodeEvents :: Header -> Decoder Event
- decodeEventLog :: Decoder Event
- readHeader :: ByteString -> Either String (Header, ByteString)
- readEvents :: Header -> ByteString -> ([Event], Maybe String)
- readEvents' :: Header -> ByteString -> [Either String Event]
- readEventLog :: ByteString -> Either String (EventLog, Maybe String)
- readEventLogOrFail :: ByteString -> Either String EventLog
Incremental API
The unfolding of the decoding process.
Consume (ByteString -> Decoder a) | The decoder has consumed all the available input and needs more to continue. |
Produce !a (Decoder a) | The decoder has returned a decoded value and the next decoder state to continue. |
Done ByteString | The decoder has ended with leftover input. |
Error ByteString String | The decoder has encountered an error with leftover input and an error message. |
decodeHeader :: Decoder Header Source #
Decode a header
decodeEventLog :: Decoder Event Source #
Decode a header and events
Lazy API
readHeader :: ByteString -> Either String (Header, ByteString) Source #
Read a header from a lazy bytestring and return the header and the leftover input for subsequent decoding.
Note that the input must contain a whole header in one go. If incremental
parsing of a header is necessary, use decodeHeader
instead.
readEvents :: Header -> ByteString -> ([Event], Maybe String) Source #
Read events from a lazy bytestring. It returns an error message if it encounters an error while decoding the header.
Note that it doesn't fail if it consumes all input in the middle of decoding of an event.
readEvents' :: Header -> ByteString -> [Either String Event] Source #
Read events from a lazy bytestring. It returns an error message if it encounters an error while decoding the header.
Note that it doesn't fail if it consumes all input in the middle of decoding of an event.
readEventLog :: ByteString -> Either String (EventLog, Maybe String) Source #
Read an entire event log from a lazy bytestring. It returns an error message if it encounters an error while decoding.
Note that it doesn't fail if it consumes all input in the middle of decoding of an event.
readEventLogOrFail :: ByteString -> Either String EventLog Source #
Read an entire event log from a lazy bytestring. It returns an error message if it encounters an error while decoding.
This will raise an error if a malformed event is encountered during decoding.