Safe Haskell | None |
---|
An applicative version of parser. This provides a restricted parser which has only an applicative instance.
- type Parser = TwistRF ParseAction BytesMonoid
- parseWidth :: Parser a -> BYTES Int
- parseError :: String -> Parser a
- unsafeRunParser :: Parser a -> Pointer -> IO a
- parse :: EndianStore a => Parser a
- parseStorable :: Storable a => Parser a
- parseVector :: (EndianStore a, Vector v a) => Int -> Parser (v a)
- parseStorableVector :: (Storable a, Vector v a) => Int -> Parser (v a)
- unsafeParseVector :: (EndianStore a, Vector v a) => Int -> Parser (v a)
- unsafeParseStorableVector :: (Storable a, Vector v a) => Int -> Parser (v a)
- parseByteString :: LengthUnit l => l -> Parser ByteString
Documentation
type Parser = TwistRF ParseAction BytesMonoidSource
An applicative parser type for reading data from a pointer.
parseWidth :: Parser a -> BYTES IntSource
Return the bytes that this parser will read.
parseError :: String -> Parser aSource
A parser that fails with a given error message.
unsafeRunParser :: Parser a -> Pointer -> IO aSource
Run the parser without checking the length constraints.
parse :: EndianStore a => Parser aSource
Parse a crypto value. Endian safety is take into account
here. This is what you would need when you parse packets from an
external source. You can also use this to define the load
function in a complicated EndianStore
instance.
parseStorable :: Storable a => Parser aSource
parseVector :: (EndianStore a, Vector v a) => Int -> Parser (v a)Source
Parses a vector of elements. It takes care of the correct endian conversion. This is the function to use while parsing external data.
parseStorableVector :: (Storable a, Vector v a) => Int -> Parser (v a)Source
Similar to parseVector
but parses according to the host
endian. This function is essentially used to define storable
instances of complicated data. It is unlikely to be of use when
parsing externally serialised data as one would want to keep track
of the endianness of the data.
unsafeParseVector :: (EndianStore a, Vector v a) => Int -> Parser (v a)Source
Similar to parseVector
but is expected to be slightly
faster. It does not check whether the length parameter is
non-negative and hence is unsafe. Use it only if you can prove that
the length parameter is non-negative.
unsafeParseStorableVector :: (Storable a, Vector v a) => Int -> Parser (v a)Source
Similar to parseStorableVector
but is expected to be slightly
faster. It does not check whether the length parameter is
non-negative and hence is unsafe. Use it only if you can prove that
the length parameter is non-negative.
parseByteString :: LengthUnit l => l -> Parser ByteStringSource
Parses a strict bytestring of a given length.