raaz-0.0.2: The raaz cryptographic library.

Safe HaskellNone

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 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

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 ByteStringSource

Parses a strict bytestring of a given length.