Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data BinaryParser a
- run :: BinaryParser a -> ByteString -> Either Text a
- failure :: Text -> BinaryParser a
- byte :: BinaryParser Word8
- matchingByte :: (Word8 -> Either Text a) -> BinaryParser a
- bytesOfSize :: Int -> BinaryParser ByteString
- bytesWhile :: (Word8 -> Bool) -> BinaryParser ByteString
- unitOfSize :: Int -> BinaryParser ()
- unitOfBytes :: ByteString -> BinaryParser ()
- unitWhile :: (Word8 -> Bool) -> BinaryParser ()
- remainders :: BinaryParser ByteString
- fold :: (a -> Word8 -> Maybe a) -> a -> BinaryParser a
- endOfInput :: BinaryParser ()
- sized :: Int -> BinaryParser a -> BinaryParser a
- storableOfSize :: Storable a => Int -> BinaryParser a
- beWord16 :: BinaryParser Word16
- leWord16 :: BinaryParser Word16
- beWord32 :: BinaryParser Word32
- leWord32 :: BinaryParser Word32
- beWord64 :: BinaryParser Word64
- leWord64 :: BinaryParser Word64
- asciiIntegral :: Integral a => BinaryParser a
Documentation
data BinaryParser a Source #
A highly-efficient parser specialised for strict ByteString
s.
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.
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.