pinch-0.3.0.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.

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.

double :: Parser Double Source

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

take :: Int -> Parser ByteString Source

take n gets exactly n bytes or fails the parse.