Module

Text.Parsing.Parser.DataView

Package
purescript-parsing-dataview
Repository
jamesdbrock/purescript-parsing-dataview

Primitive parsers for parsing Javascript ArrayBuffers with the Text.Parsing.Parser module in package purescript-parsing. See the package README for usage examples.

All of the parsers in this module operate on an input stream of Data.ArrayBuffer.Types.DataView, which represents a range of an Data.ArrayBuffer.Types.ArrayBuffer.

For operations for working with ArrayBuffer and DataView, see module Data.ArrayBuffer.DataView in package purescript-arraybuffer.

Reading from an ArrayBuffer is an Effectful activity, so all parsers in this module must be run in a MonadEffect m => ParserT DataView m context, with Text.Parsing.Parser.runParserT.

#anyPrim Source

anyPrim :: forall a name m t. BinaryValue a t => BytesPerType a => ShowArrayViewType a name => IsSymbol name => MonadEffect m => Endian -> Proxy a -> ParserT DataView m t

Parse one fixed-bit-width Data.ArrayBuffer.Types.ArrayViewType primitive of a given endianness.

Example

Parse a little-endian 32-bit signed integer (4 bytes):

anyPrim LE (Proxy :: Proxy Int32)

or just use the convenience function anyInt32le, see below.

#anyInt8 Source

anyInt8 :: forall m. MonadEffect m => ParserT DataView m Int

Parse one 8-bit signed integer (byte).

#anyInt16be Source

anyInt16be :: forall m. MonadEffect m => ParserT DataView m Int

Parse one 16-bit big-endian signed integer.

#anyInt16le Source

anyInt16le :: forall m. MonadEffect m => ParserT DataView m Int

Parse one 16-bit little-endian signed integer.

#anyInt32be Source

anyInt32be :: forall m. MonadEffect m => ParserT DataView m Int

Parse one 32-bit big-endian signed integer.

#anyInt32le Source

anyInt32le :: forall m. MonadEffect m => ParserT DataView m Int

Parse one 32-bit little-endian signed integer.

#anyUint8 Source

anyUint8 :: forall m. MonadEffect m => ParserT DataView m UInt

Parse one 8-bit unsigned integer (octet).

#anyUint16be Source

anyUint16be :: forall m. MonadEffect m => ParserT DataView m UInt

Parse one 16-bit big-endian unsigned integer.

#anyUint16le Source

anyUint16le :: forall m. MonadEffect m => ParserT DataView m UInt

Parse one 16-bit little-endian unsigned integer.

#anyUint32be Source

anyUint32be :: forall m. MonadEffect m => ParserT DataView m UInt

Parse one 32-bit big-endian unsigned integer.

#anyUint32le Source

anyUint32le :: forall m. MonadEffect m => ParserT DataView m UInt

Parse one 32-bit little-endian unsigned integer.

#anyFloat32be Source

anyFloat32be :: forall m. MonadEffect m => ParserT DataView m Float32

Parse one 32-bit big-endian floating point number.

#anyFloat32le Source

anyFloat32le :: forall m. MonadEffect m => ParserT DataView m Float32

Parse one 32-bit little-endian floating point number.

#anyFloat64be Source

anyFloat64be :: forall m. MonadEffect m => ParserT DataView m Number

Parse one 64-bit big-endian floating point number.

#anyFloat64le Source

anyFloat64le :: forall m. MonadEffect m => ParserT DataView m Number

Parse one 64-bit little-endian floating point number.

#satisfy Source

satisfy :: forall a name m t. BinaryValue a t => BytesPerType a => ShowArrayViewType a name => IsSymbol name => Show t => MonadEffect m => Endian -> Proxy a -> (t -> Boolean) -> ParserT DataView m t

Parse one fixed-bit-width primitive that satisfies the given predicate.

Example

Parse a little-endian 32-bit signed integer that is equal to 3:

satisfy LE (Proxy :: Proxy Int32) (_ == 3)

or just use the convenience function satisfyInt32le, see below.

#satisfyInt8 Source

satisfyInt8 :: forall m. MonadEffect m => (Int -> Boolean) -> ParserT DataView m Int

Parse one 8-bit signed integer that satisfies the given predicate.

#satisfyInt16be Source

satisfyInt16be :: forall m. MonadEffect m => (Int -> Boolean) -> ParserT DataView m Int

Parse one 16-bit big-endian signed integer that satisfies the given predicate.

#satisfyInt16le Source

satisfyInt16le :: forall m. MonadEffect m => (Int -> Boolean) -> ParserT DataView m Int

Parse one 16-bit little-endian signed integer that satisfies the given predicate.

#satisfyInt32be Source

satisfyInt32be :: forall m. MonadEffect m => (Int -> Boolean) -> ParserT DataView m Int

Parse one 32-bit big-endian signed integer that satisfies the given predicate.

#satisfyInt32le Source

satisfyInt32le :: forall m. MonadEffect m => (Int -> Boolean) -> ParserT DataView m Int

Parse one 32-bit little-endian signed integer that satisfies the given predicate.

#satisfyUint8 Source

satisfyUint8 :: forall m. MonadEffect m => (UInt -> Boolean) -> ParserT DataView m UInt

Parse one 8-bit unsigned integer that satisfies the given predicate.

#satisfyUint16be Source

satisfyUint16be :: forall m. MonadEffect m => (UInt -> Boolean) -> ParserT DataView m UInt

Parse one 16-bit big-endian unsigned integer that satisfies the given predicate.

#satisfyUint16le Source

satisfyUint16le :: forall m. MonadEffect m => (UInt -> Boolean) -> ParserT DataView m UInt

Parse one 16-bit little-endian unsigned integer that satisfies the given predicate.

#satisfyUint32be Source

satisfyUint32be :: forall m. MonadEffect m => (UInt -> Boolean) -> ParserT DataView m UInt

Parse one 32-bit big-endian unsigned integer that satisfies the given predicate.

#satisfyUint32le Source

satisfyUint32le :: forall m. MonadEffect m => (UInt -> Boolean) -> ParserT DataView m UInt

Parse one 32-bit little-endian unsigned integer that satisfies the given predicate.

#satisfyFloat32be Source

satisfyFloat32be :: forall m. MonadEffect m => (Float32 -> Boolean) -> ParserT DataView m Float32

Parse one 32-bit big-endian floating-point number that satisfies the given predicate.

#satisfyFloat32le Source

satisfyFloat32le :: forall m. MonadEffect m => (Float32 -> Boolean) -> ParserT DataView m Float32

Parse one 32-bit little-endian floating-point number that satisfies the given predicate.

#satisfyFloat64be Source

satisfyFloat64be :: forall m. MonadEffect m => (Number -> Boolean) -> ParserT DataView m Number

Parse one 64-bit big-endian floating-point number that satisfies the given predicate.

#satisfyFloat64le Source

satisfyFloat64le :: forall m. MonadEffect m => (Number -> Boolean) -> ParserT DataView m Number

Parse one 64-bit little-endian floating-point number that satisfies the given predicate.

#takeN Source

takeN :: forall m. MonadEffect m => ByteLength -> ParserT DataView m DataView

Take N bytes starting from the current parser position. Will fail if not enough bytes remain in the input. Will fail if N is negative.

Example

Parse three bytes.

takeN 3

#takeRest Source

takeRest :: forall m. MonadEffect m => ParserT DataView m DataView

Take the rest of the input, however many bytes remain. Always succeeds.

#eof Source

eof :: forall m. Monad m => ParserT DataView m Unit

Parse succeeds at the end of the input DataView. Consumes no input.

#match Source

match :: forall a m. MonadEffect m => ParserT DataView m a -> ParserT DataView m (Tuple DataView a)

The famous match combinator.

Return both the result of a parse and the portion of the input that was consumed while it was being parsed.