Data.Bytes.Parser.Leb128

bytesmith-0.3.11.1: Nonresumable byte parser

Safe Haskell | None
Language | Haskell2010

Data.Bytes.Parser.Leb128

Contents

- Unsigned
- Signed (Zig-zag)

Description

Parse numbers that have been encoded with LEB-128. LEB-128 allows arbitrarily large numbers to be encoded. Parsers in this module will fail if the number they attempt to parse is outside the range of what their target type can handle. The parsers for signed numbers assume that the numbers have been zigzig encoded.

Synopsis

- word16 :: e -> Parser e s Word16
- word32 :: e -> Parser e s Word32
- word64 :: e -> Parser e s Word64
- int16 :: e -> Parser e s Int16
- int32 :: e -> Parser e s Int32
- int64 :: e -> Parser e s Int64

# Unsigned

word16 :: e -> Parser e s Word16 #

Parse a LEB-128-encoded number. If the number is larger than `0xFFFF`, fails with the provided error.

word32 :: e -> Parser e s Word32 #

Parse a LEB-128-encoded number. If the number is larger than `0xFFFFFFFF`, fails with the provided error.

word64 :: e -> Parser e s Word64 #

Parse a LEB-128-encoded number. If the number is larger than `0xFFFFFFFFFFFFFFFF`, fails with the provided error.

# Signed (Zig-zag)

int16 :: e -> Parser e s Int16 #

Parse a LEB-128-zigzag-encoded signed number. If the encoded number is outside the range `[-32768,32767]`, this fails with the provided error.

int32 :: e -> Parser e s Int32 #

Parse a LEB-128-zigzag-encoded signed number. If the encoded number is outside the range `[-2147483648,2147483647]`, this fails with the provided error.

int64 :: e -> Parser e s Int64 #

Parse a LEB-128-zigzag-encoded signed number. If the encoded number is outside the range `[-9223372036854775808,9223372036854775807]`, this fails with the provided error.