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

Safe HaskellNone
LanguageHaskell2010

BinaryParser

Contents

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.

matchingByte :: (Word8 -> Either Text a) -> BinaryParser a Source #

Consume a single byte, which satisfies the predicate.

bytesOfSize :: Int -> BinaryParser ByteString Source #

Consume an amount of bytes.

bytesWhile :: (Word8 -> Bool) -> BinaryParser ByteString Source #

Consume multiple bytes, which satisfy the predicate.

unitOfSize :: Int -> BinaryParser () Source #

Skip an amount of bytes.

unitOfBytes :: ByteString -> BinaryParser () Source #

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

unitWhile :: (Word8 -> Bool) -> BinaryParser () Source #

Skip bytes, which satisfy the predicate.

remainders :: BinaryParser ByteString Source #

Consume all the remaining bytes.

fold :: (a -> Word8 -> Maybe a) -> a -> BinaryParser a Source #

Left-fold the bytes, terminating before the byte, on which the step function returns Nothing.

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.

Extras

storableOfSize :: Storable a => Int -> BinaryParser a Source #

Storable value of the given amount of bytes.

beWord16 :: BinaryParser Word16 Source #

Big-endian word of 2 bytes.

leWord16 :: BinaryParser Word16 Source #

Little-endian word of 2 bytes.

beWord32 :: BinaryParser Word32 Source #

Big-endian word of 4 bytes.

leWord32 :: BinaryParser Word32 Source #

Little-endian word of 4 bytes.

beWord64 :: BinaryParser Word64 Source #

Big-endian word of 8 bytes.

leWord64 :: BinaryParser Word64 Source #

Little-endian word of 8 bytes.

asciiIntegral :: Integral a => BinaryParser a Source #

Integral number encoded in ASCII.