pinch-0.3.4.1: An alternative implementation of Thrift for Haskell.

Copyright(c) Abhinav Gupta 2015
LicenseBSD3
MaintainerAbhinav Gupta <mail@abhinavg.net>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Pinch.Internal.Parser

Description

Implements a basic parser for binary data. The parser does not do any extra book-keeping besides keeping track of the current position in the ByteString.

Synopsis

Documentation

data Parser a Source #

A simple ByteString parser.

Instances
Monad Parser Source # 
Instance details

Defined in Pinch.Internal.Parser

Methods

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

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

return :: a -> Parser a #

fail :: String -> Parser a #

Functor Parser Source # 
Instance details

Defined in Pinch.Internal.Parser

Methods

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

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

Applicative Parser Source # 
Instance details

Defined in Pinch.Internal.Parser

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 #

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

Run the parser on the given ByteString. Return either the failure message or the result.

runParser' :: Parser a -> ByteString -> Either String (ByteString, a) Source #

Run the parser on the given ByteString. Return either the failure message or the result and any left-over content.

int8 :: Parser Int8 Source #

Produces the next byte and advances the parser.

word8 :: Parser Word8 Source #

Produces the next byte and advances the parser.

int16 :: Parser Int16 Source #

Produces a signed 16-bit integer and advances the parser.

int32 :: Parser Int32 Source #

Produces a signed 32-bit integer and advances the parser.

int64 :: Parser Int64 Source #

Produces a signed 64-bit integer and advances the parser.

int64LE :: Parser Int64 Source #

Produces a signed 64-bit integer (parsed in little endian byte ordering) and advances the parser.

double :: Parser Double Source #

Produces a 64-bit floating point number and advances the parser.

doubleLE :: Parser Double Source #

Produces a 64-bit floating point number (parsed in little endian byte ordering) and advances the parser.

take :: Int -> Parser ByteString Source #

take n gets exactly n bytes or fails the parse.