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

Safe Haskell | None
Language | Haskell2010

BinaryParser

Synopsis

- data BinaryParser a
- run :: BinaryParser a -> ByteString -> Either Text a
- failure :: Text -> BinaryParser a
- byte :: BinaryParser Word8
- bytesOfSize :: Int -> BinaryParser ByteString
- unitOfSize :: Int -> BinaryParser ()
- unitOfBytes :: ByteString -> BinaryParser ()
- remainders :: BinaryParser ByteString
- endOfInput :: BinaryParser ()
- sized :: Int -> BinaryParser a -> BinaryParser a

# Documentation

data BinaryParser a #

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.

Instances

Monad BinaryParser # |
Methods (>>=) :: BinaryParser a -> (a -> BinaryParser b) -> BinaryParser b # (>>) :: BinaryParser a -> BinaryParser b -> BinaryParser b # return :: a -> BinaryParser a # fail :: String -> BinaryParser a #
Functor BinaryParser # |
Methods fmap :: (a -> b) -> BinaryParser a -> BinaryParser b # (<$) :: a -> BinaryParser b -> BinaryParser a #
Applicative BinaryParser # |
Methods pure :: a -> BinaryParser a # (<*>) :: BinaryParser (a -> b) -> BinaryParser a -> BinaryParser b # (*>) :: BinaryParser a -> BinaryParser b -> BinaryParser b # (<*) :: BinaryParser a -> BinaryParser b -> BinaryParser a #
Alternative BinaryParser # |
Methods empty :: BinaryParser a # (<|>) :: BinaryParser a -> BinaryParser a -> BinaryParser a # some :: BinaryParser a -> BinaryParser [a] # many :: BinaryParser a -> BinaryParser [a] #
MonadPlus BinaryParser # |
Methods mzero :: BinaryParser a # mplus :: BinaryParser a -> BinaryParser a -> BinaryParser a #

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

Apply a parser to bytes.

failure :: Text -> BinaryParser a #

Fail with a message.

byte :: BinaryParser Word8 #

Consume a single byte.

bytesOfSize :: Int -> BinaryParser ByteString #

Consume an amount of bytes.

unitOfSize :: Int -> BinaryParser () #

Skip an amount of bytes.

unitOfBytes :: ByteString -> BinaryParser () #

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

remainders :: BinaryParser ByteString #

Consume all the remaining bytes.

endOfInput :: BinaryParser () #

Fail if the input hasn't ended.

sized :: Int -> BinaryParser a -> BinaryParser a #

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