asn1-parse-0.9.5: Simple monadic parser for ASN1 stream types.

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | experimental
Portability | unknown
Safe Haskell | None
Language | Haskell98

Data.ASN1.Parse

Contents

- run
- combinators

Description

A parser combinator for ASN1 Stream.

Synopsis

- data ParseASN1 a
- runParseASN1State :: ParseASN1 a -> [ASN1] -> Either String (a, [ASN1])
- runParseASN1 :: ParseASN1 a -> [ASN1] -> Either String a
- throwParseError :: String -> ParseASN1 a
- onNextContainer :: ASN1ConstructionType -> ParseASN1 a -> ParseASN1 a
- onNextContainerMaybe :: ASN1ConstructionType -> ParseASN1 a -> ParseASN1 (Maybe a)
- getNextContainer :: ASN1ConstructionType -> ParseASN1 [ASN1]
- getNextContainerMaybe :: ASN1ConstructionType -> ParseASN1 (Maybe [ASN1])
- getNext :: ParseASN1 ASN1
- getNextMaybe :: (ASN1 -> Maybe a) -> ParseASN1 (Maybe a)
- hasNext :: ParseASN1 Bool
- getObject :: ASN1Object a => ParseASN1 a
- getMany :: ParseASN1 a -> ParseASN1 [a]

# Documentation

data ParseASN1 a Source #

#### Instances

Instances details

Alternative ParseASN1 Source # |
Instance details Defined in Data.ASN1.Parse Methods empty :: ParseASN1 a Source # (<|>) :: ParseASN1 a -> ParseASN1 a -> ParseASN1 a Source # some :: ParseASN1 a -> ParseASN1 [a] Source # many :: ParseASN1 a -> ParseASN1 [a] Source #
Applicative ParseASN1 Source # |
Instance details Defined in Data.ASN1.Parse Methods pure :: a -> ParseASN1 a Source # (<*>) :: ParseASN1 (a -> b) -> ParseASN1 a -> ParseASN1 b Source # liftA2 :: (a -> b -> c) -> ParseASN1 a -> ParseASN1 b -> ParseASN1 c Source # (*>) :: ParseASN1 a -> ParseASN1 b -> ParseASN1 b Source # (<*) :: ParseASN1 a -> ParseASN1 b -> ParseASN1 a Source #
Functor ParseASN1 Source # |
Instance details Defined in Data.ASN1.Parse Methods fmap :: (a -> b) -> ParseASN1 a -> ParseASN1 b Source # (<$) :: a -> ParseASN1 b -> ParseASN1 a Source #
Monad ParseASN1 Source # |
Instance details Defined in Data.ASN1.Parse Methods (>>=) :: ParseASN1 a -> (a -> ParseASN1 b) -> ParseASN1 b Source # (>>) :: ParseASN1 a -> ParseASN1 b -> ParseASN1 b Source # return :: a -> ParseASN1 a Source #
MonadFail ParseASN1 Source # |
Instance details Defined in Data.ASN1.Parse Methods fail :: String -> ParseASN1 a Source #

# run

runParseASN1State :: ParseASN1 a -> [ASN1] -> Either String (a, [ASN1]) Source #

run the parse monad over a stream and returns the result and the remaining ASN1 Stream.

runParseASN1 :: ParseASN1 a -> [ASN1] -> Either String a Source #

run the parse monad over a stream and returns the result.

If there's still some asn1 object in the state after calling f, an error will be raised.

throwParseError :: String -> ParseASN1 a Source #

throw a parse error

# combinators

onNextContainer :: ASN1ConstructionType -> ParseASN1 a -> ParseASN1 a Source #

run a function of the next elements of a container of specified type

onNextContainerMaybe :: ASN1ConstructionType -> ParseASN1 a -> ParseASN1 (Maybe a) Source #

just like onNextContainer, except it doesn't throw an error if the container doesn't exists.

getNextContainer :: ASN1ConstructionType -> ParseASN1 [ASN1] Source #

get next container of specified type and return all its elements

getNextContainerMaybe :: ASN1ConstructionType -> ParseASN1 (Maybe [ASN1]) Source #

just like getNextContainer, except it doesn't throw an error if the container doesn't exists.

getNext :: ParseASN1 ASN1 Source #

get next element from the stream

getNextMaybe :: (ASN1 -> Maybe a) -> ParseASN1 (Maybe a) Source #

get next element from the stream maybe

hasNext :: ParseASN1 Bool Source #

returns if there's more elements in the stream.

getObject :: ASN1Object a => ParseASN1 a Source #

get next object

getMany :: ParseASN1 a -> ParseASN1 [a] Source #

get many elements until there's nothing left