Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
- runParser :: Parser a -> ByteString -> Maybe 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 BytesMonoid Source #
An applicative parser type for reading data from a pointer.
parseError :: String -> Parser a Source #
A parser that fails with a given error message.
runParser :: Parser a -> ByteString -> Maybe a Source #
Runs a parser on a byte string. It returns Nothing
if the byte string is smaller than
what the parser would consume.
unsafeRunParser :: Parser a -> Pointer -> IO a Source #
Run the parser without checking the length constraints.
parse :: EndianStore a => Parser a Source #
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 a Source #
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 ByteString Source #
Parses a strict bytestring of a given length.