conduit-parse-0.2.1.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

MonadError ConduitParserException (ConduitParser i m) Source #

Backtracking is supported by pushing back consumed elements (using leftover) whenever an error is catched.

As a consequence, within the scope of a catchError, all streamed items are kept in memory, which means the consumer no longer uses constant memory.

MonadTrans (ConduitParser i) Source # 

Methods

lift :: Monad m => m a -> ConduitParser i m a #

Monad (ConduitParser i m) Source # 

Methods

(>>=) :: ConduitParser i m a -> (a -> ConduitParser i m b) -> ConduitParser i m b #

(>>) :: ConduitParser i m a -> ConduitParser i m b -> ConduitParser i m b #

return :: a -> ConduitParser i m a #

fail :: String -> ConduitParser i m a #

Functor (ConduitParser i m) Source # 

Methods

fmap :: (a -> b) -> ConduitParser i m a -> ConduitParser i m b #

(<$) :: a -> ConduitParser i m b -> ConduitParser i m a #

Applicative (ConduitParser i m) Source # 

Methods

pure :: a -> ConduitParser i m a #

(<*>) :: ConduitParser i m (a -> b) -> ConduitParser i m a -> ConduitParser i m b #

liftA2 :: (a -> b -> c) -> ConduitParser i m a -> ConduitParser i m b -> ConduitParser i m c #

(*>) :: ConduitParser i m a -> ConduitParser i m b -> ConduitParser i m b #

(<*) :: ConduitParser i m a -> ConduitParser i m b -> ConduitParser i m a #

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 throwError or unexpected instead.

Methods

empty :: ConduitParser i m a #

(<|>) :: ConduitParser i m a -> ConduitParser i m a -> ConduitParser i m a #

some :: ConduitParser i m a -> ConduitParser i m [a] #

many :: ConduitParser i m a -> ConduitParser i m [a] #

MonadIO m => MonadIO (ConduitParser i m) Source # 

Methods

liftIO :: IO a -> ConduitParser i m a #

MonadThrow m => MonadThrow (ConduitParser i m) Source # 

Methods

throwM :: Exception e => e -> ConduitParser i m a #

Monad m => Parsing (ConduitParser i m) Source #

Parsing combinators can be used with ConduitParsers.

runConduitParser :: MonadThrow m => ConduitParser i m a -> ConduitT i Void m a Source #

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

named :: Monad m => Text -> ConduitParser i m a -> ConduitParser i m a Source #

Flipped version of (<?>).

Primitives

await :: Monad m => ConduitParser i m i Source #

await wrapped as a ConduitParser.

If no data is available, UnexpectedEndOfInput is thrown.

leftover :: i -> ConduitParser i m () Source #

leftover wrapped as a ConduitParser.

getParserNames :: ConduitParser i m [Text] Source #

Return the ordered list of names (assigned through (<?>)) for the current parser stack. First element is the most nested parser.

getParserName :: ConduitParser i m Text Source #

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

Utility

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

peek wrapped as a ConduitParser.

Exception