proto-lens-0.5.1.0: A lens-based implementation of protocol buffers in Haskell.

Data.ProtoLens.Encoding.Parser

Description

A custom parsing monad, optimized for speed.

Synopsis

# Documentation

data Parser a Source #

A monad for parsing an input buffer.

Instances
 Source # Instance detailsDefined in Data.ProtoLens.Encoding.Parser.Internal Methods(>>=) :: Parser a -> (a -> Parser b) -> Parser b #(>>) :: Parser a -> Parser b -> Parser b #return :: a -> Parser a #fail :: String -> Parser a # Source # Instance detailsDefined in Data.ProtoLens.Encoding.Parser.Internal Methodsfmap :: (a -> b) -> Parser a -> Parser b #(<\$) :: a -> Parser b -> Parser a # Source # Instance detailsDefined in Data.ProtoLens.Encoding.Parser.Internal Methodspure :: a -> Parser a #(<*>) :: Parser (a -> b) -> Parser a -> Parser b #liftA2 :: (a -> b -> c) -> Parser a -> Parser b -> Parser c #(*>) :: Parser a -> Parser b -> Parser b #(<*) :: Parser a -> Parser b -> Parser a #

Evaluates a parser on the given input.

If the parser does not consume all of the input, the rest of the input is discarded and the parser still succeeds. Parsers may use atEnd to detect whether they are at the end of the input.

Values returned from actions in this monad will not hold onto the original ByteString, but rather make immutable copies of subsets of its bytes.

Returns True if there is no more input left to consume.

isolate :: Int -> Parser a -> Parser a Source #

Run the given parsing action as if there are only len bytes remaining. That is, once len bytes have been consumed, atEnd will return True and other actions like getWord8 will act like there is no input remaining.

Fails the parse if given a negative length.

Parse a one-byte word.

Parser a 4-byte word in little-endian order.

Parse a sequence of zero or more bytes of the given length.

The new ByteString is an immutable copy of the bytes in the input and will be managed separately on the Haskell heap from the original input ByteString.

Fails the parse if given a negative length.

(<?>) :: Parser a -> String -> Parser a Source #

If the parser fails, prepend an error message.