proto-lens-0.7.1.4: A lens-based implementation of protocol buffers in Haskell.
Safe HaskellSafe-Inferred
LanguageHaskell2010

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

Instances details
MonadFail Parser Source # 
Instance details

Defined in Data.ProtoLens.Encoding.Parser.Internal

Methods

fail :: String -> Parser a #

Applicative Parser Source # 
Instance details

Defined in Data.ProtoLens.Encoding.Parser.Internal

Methods

pure :: 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 #

Functor Parser Source # 
Instance details

Defined in Data.ProtoLens.Encoding.Parser.Internal

Methods

fmap :: (a -> b) -> Parser a -> Parser b #

(<$) :: a -> Parser b -> Parser a #

Monad Parser Source # 
Instance details

Defined in Data.ProtoLens.Encoding.Parser.Internal

Methods

(>>=) :: Parser a -> (a -> Parser b) -> Parser b #

(>>) :: Parser a -> Parser b -> Parser b #

return :: a -> Parser a #

runParser :: Parser a -> ByteString -> Either String a Source #

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.

atEnd :: Parser Bool Source #

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.

getWord8 :: Parser Word8 Source #

Parse a one-byte word.

getWord32le :: Parser Word32 Source #

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

getBytes :: Int -> Parser ByteString Source #

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.