conduit-parse-0.1.0.0: Parsing framework based on conduit.

Safe HaskellNone
LanguageHaskell2010

Data.Conduit.Parser

Contents

Description

This module introduces ConduitParser, a wrapper around Sink that behaves like a parser.

You probably want to import the Text.Parser.Combinators module together with this module.

Synopsis

Conduit parser monad

data ConduitParser i m a Source

Core type of the package. This is basically a Sink with a parsing state.

Instances

MonadTrans (ConduitParser i) Source 
Monad m => Monad (ConduitParser i m) Source 
Functor (ConduitParser i m) Source 
Applicative (ConduitParser i m) Source 
MonadCatch m => Alternative (ConduitParser i m) Source

Parsers can be combined with (<|>), some, many, optional, choice.

The use of guard is not recommended as it generates unhelpful error messages. Please consider using throwM or unexpected instead.

Note: only ConduitParserExceptions will trigger the Alternative features, all other exceptions are rethrown.

MonadThrow m => MonadThrow (ConduitParser i m) Source

Consumed elements are pushed back with leftover whenever an exception occurs. In other words, backtracking is supported.

MonadCatch m => MonadCatch (ConduitParser i m) Source 
MonadCatch m => Parsing (ConduitParser i m) Source

Parsing combinators can be used with ConduitParsers.

runConduitParser :: MonadThrow m => ConduitParser i m a -> Sink i m a Source

Run a ConduitParser. Any parsing failure will be thrown as an exception.

named :: MonadCatch m => Text -> ConduitParser i m a -> ConduitParser i m a Source

Flipped version of (<?>).

Primitives

await :: MonadCatch m => ConduitParser i m i Source

await wrapped as a ConduitParser.

If no data is available, UnexpectedEndOfInput is thrown.

leftover :: Monad m => i -> ConduitParser i m () Source

leftover wrapped as a ConduitParser.

getParserName :: ConduitParser i m Text Source

Return the name of the parser (assigned through (<?>)), or mempty if has none.

Utility

peek :: Monad m => ConduitParser i m (Maybe i) Source

peek wrapped as a ConduitParser.

Exception