Safe Haskell | None |
---|---|
Language | Haskell2010 |
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.
- newtype ConduitParser i m a = ConduitParser (ExceptT ConduitParserException (StateT ([Text], Buffer i) (Sink i m)) a)
- runConduitParser :: MonadThrow m => ConduitParser i m a -> Sink i m a
- named :: Monad m => Text -> ConduitParser i m a -> ConduitParser i m a
- await :: Monad m => ConduitParser i m i
- anyOne :: Monad m => ConduitParser i m i
- leftover :: i -> ConduitParser i m ()
- getParserNames :: ConduitParser i m [Text]
- getParserName :: ConduitParser i m Text
- peek :: Monad m => ConduitParser i m (Maybe i)
- data ConduitParserException
- parseC :: MonadThrow m => ConduitParser i m a -> Conduit i m a
- parseOrSkipC :: MonadThrow m => ConduitParser i m a -> ConduitParser i m b -> Conduit i m a
- lastRequired :: MonadThrow m => Text -> Consumer a m a
- lastDef :: MonadThrow m => a -> Consumer a m a
- embed :: MonadCatch m => Sink i m a -> ConduitParser i m a
Conduit parser monad
newtype ConduitParser i m a Source #
Core type of the package. This is basically a Sink
with a parsing state.
ConduitParser (ExceptT ConduitParserException (StateT ([Text], Buffer i) (Sink i m)) a) |
MonadError ConduitParserException (ConduitParser i m) Source # | Backtracking is supported by pushing back consumed elements (using As a consequence, within the scope of a |
MonadTrans (ConduitParser i) Source # | |
Monad (ConduitParser i m) Source # | |
Functor (ConduitParser i m) Source # | |
Applicative (ConduitParser i m) Source # | |
Alternative (ConduitParser i m) Source # | Parsers can be combined with ( The use of |
MonadIO m => MonadIO (ConduitParser i m) Source # | |
MonadThrow m => MonadThrow (ConduitParser i m) Source # | |
MonadCatch m => MonadCatch (ConduitParser i m) Source # | |
Monad m => CharParsing (ConduitParser Char m) Source # | |
Monad m => Parsing (ConduitParser i m) Source # | Parsing combinators can be used with |
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 :: 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 #
Utility
peek :: Monad m => ConduitParser i m (Maybe i) Source #
peek
wrapped as a ConduitParser
.
Exception
data ConduitParserException Source #
BothFailed ConduitParserException ConduitParserException | |
ExpectedEndOfInput | |
NamedParserException Text ConduitParserException | |
UnexpectedEndOfInput | |
UnexpectedFollowedBy Text | |
Unexpected Text |
Eq ConduitParserException Source # | |
Show ConduitParserException Source # | |
Exception ConduitParserException Source # | |
MonadError ConduitParserException (ConduitParser i m) Source # | Backtracking is supported by pushing back consumed elements (using As a consequence, within the scope of a |
Utilities
parseC :: MonadThrow m => ConduitParser i m a -> Conduit i m a Source #
Turn a parser into a regular Conduit
that yields parsed items as long as the parser succeeds.
Once the parser fails, the conduit stops consuming input and won't yield any more.
parseOrSkipC :: MonadThrow m => ConduitParser i m a -> ConduitParser i m b -> Conduit i m a Source #
lastRequired :: MonadThrow m => Text -> Consumer a m a Source #
lastDef :: MonadThrow m => a -> Consumer a m a Source #
embed :: MonadCatch m => Sink i m a -> ConduitParser i m a Source #