binary-parser-0.5: A highly-efficient but limited parser API specialised for bytestrings

Safe HaskellNone
LanguageHaskell2010

BinaryParser

Synopsis

Documentation

data BinaryParser a Source

A highly-efficient parser specialised for strict ByteStrings.

Supports the roll-back and alternative branching on the basis of the Alternative interface.

Does not generate fancy error-messages, which contributes to its efficiency.

run :: BinaryParser a -> ByteString -> Either Text a Source

Apply a parser to bytes.

failure :: Text -> BinaryParser a Source

Fail with a message.

byte :: BinaryParser Word8 Source

Consume a single byte.

bytesOfSize :: Int -> BinaryParser ByteString Source

Consume an amount of bytes.

unitOfSize :: Int -> BinaryParser () Source

Skip an amount of bytes.

unitOfBytes :: ByteString -> BinaryParser () Source

Skip specific bytes, while failing if they don't match.

remainders :: BinaryParser ByteString Source

Consume all the remaining bytes.

endOfInput :: BinaryParser () Source

Fail if the input hasn't ended.

sized :: Int -> BinaryParser a -> BinaryParser a Source

Run a subparser passing it a chunk of the current input of the specified size.