Byte parsers #
Equations
- Parser.runBytes p b = Parser.runOn p (Input.ofByteArray b)
Instances For
def
Parser.runBytesOption
{α ε : Type}
{ge gc : Necessity}
(p : ByteParser ε { errors := ge, consumes := gc } α)
(b : ByteArray)
:
Option α
Equations
- Parser.runBytesOption p b = (Parser.runBytes p b).toOption
Instances For
Consume exactly k + 1 bytes.
Equations
- Parser.Byte.take1 k = (fun (x : List.Vector UInt8 (k + 1)) => x.toList.toByteArray) <$>ᵍ Parser.count1 k Parser.anyTok
Instances For
Consume all remaining input.
Instances For
@[reducible, inline]
Read an unsigned 8-bit integer.
Equations
Instances For
Read a signed 8-bit integer.
Equations
- Parser.Byte.int8 = (fun (x : UInt8) => x.toInt8) <$>ᵍ Parser.Byte.uint8
Instances For
Read a big-endian unsigned 16-bit integer.
Equations
- Parser.Byte.uint16be = Parser.Byte.uint8 >>=ᵍ fun (hi : UInt8) => Parser.Byte.uint8 >>=ᵍ fun (lo : UInt8) => gpure (hi.toUInt16 <<< 8 ||| lo.toUInt16)
Instances For
Read a little-endian unsigned 16-bit integer.
Equations
- Parser.Byte.uint16le = Parser.Byte.uint8 >>=ᵍ fun (lo : UInt8) => Parser.Byte.uint8 >>=ᵍ fun (hi : UInt8) => gpure (hi.toUInt16 <<< 8 ||| lo.toUInt16)
Instances For
Read a big-endian unsigned 32-bit integer.
Equations
- Parser.Byte.uint32be = Parser.Byte.uint16be >>=ᵍ fun (hi : UInt16) => Parser.Byte.uint16be >>=ᵍ fun (lo : UInt16) => gpure (hi.toUInt32 <<< 16 ||| lo.toUInt32)
Instances For
Read a little-endian unsigned 32-bit integer.
Equations
- Parser.Byte.uint32le = Parser.Byte.uint16le >>=ᵍ fun (lo : UInt16) => Parser.Byte.uint16le >>=ᵍ fun (hi : UInt16) => gpure (hi.toUInt32 <<< 16 ||| lo.toUInt32)
Instances For
Read a big-endian unsigned 64-bit integer.
Equations
- Parser.Byte.uint64be = Parser.Byte.uint32be >>=ᵍ fun (hi : UInt32) => Parser.Byte.uint32be >>=ᵍ fun (lo : UInt32) => gpure (hi.toUInt64 <<< 32 ||| lo.toUInt64)
Instances For
Read a little-endian unsigned 64-bit integer.
Equations
- Parser.Byte.uint64le = Parser.Byte.uint32le >>=ᵍ fun (lo : UInt32) => Parser.Byte.uint32le >>=ᵍ fun (hi : UInt32) => gpure (hi.toUInt64 <<< 32 ||| lo.toUInt64)
Instances For
Read a big-endian signed 16-bit integer.
Equations
- Parser.Byte.int16be = (fun (x : UInt16) => x.toInt16) <$>ᵍ Parser.Byte.uint16be
Instances For
Read a little-endian signed 16-bit integer.
Equations
- Parser.Byte.int16le = (fun (x : UInt16) => x.toInt16) <$>ᵍ Parser.Byte.uint16le
Instances For
Read a big-endian signed 32-bit integer.
Equations
- Parser.Byte.int32be = (fun (x : UInt32) => x.toInt32) <$>ᵍ Parser.Byte.uint32be
Instances For
Read a little-endian signed 32-bit integer.
Equations
- Parser.Byte.int32le = (fun (x : UInt32) => x.toInt32) <$>ᵍ Parser.Byte.uint32le
Instances For
Read a big-endian signed 64-bit integer.
Equations
- Parser.Byte.int64be = (fun (x : UInt64) => x.toInt64) <$>ᵍ Parser.Byte.uint64be
Instances For
Read a little-endian signed 64-bit integer.
Equations
- Parser.Byte.int64le = (fun (x : UInt64) => x.toInt64) <$>ᵍ Parser.Byte.uint64le