raaz-0.2.0: The raaz cryptographic library.

Safe HaskellNone
LanguageHaskell2010

Raaz.Core.Parse.Applicative

Description

An applicative version of parser. This provides a restricted parser which has only an applicative instance.

Synopsis

Documentation

type Parser = TwistRF ParseAction BytesMonoid Source #

An applicative parser type for reading data from a pointer.

parseWidth :: Parser a -> BYTES Int Source #

Return the bytes that this parser will read.

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 #

Parses a value which is an instance of Storable. Beware that this parser expects that the value is stored in machine endian. Mostly it is useful in defining the peek function in a complicated Storable instance.

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.

skip :: LengthUnit u => u -> Parser () Source #

Skip over some data.