| Safe Haskell | None |
|---|
Control.Proxy.Attoparsec
Contents
Description
This module provides utilities to turn your Attoparsec into a Parser a
bPipe that parses a values into b values as they flow
downstream.
See Control.Proxy.Attoparsec.Tutorial for an extensive introduction with examples.
- parserInputD :: (Monad m, Proxy p) => ParserStatus a -> p () a (ParserStatus a) (ParserSupply a) m r
- parserD :: (Proxy p, Monad m, AttoparsecInput a) => Parser a b -> () -> p (ParserStatus a) (ParserSupply a) () b m r
- module Control.Proxy.Attoparsec.Types
- module Control.Proxy.Attoparsec.Control
Parsing Pipe
A Pipe that parses a input flowing downstream into b values is
made of at least two smaller cooperating Proxys:
-
parserInputD: Preparesainput received from upstream to be consumed by a downstream parsingProxy. -
parserD: Repeatedly runs a givenon inputParsera bafrom upstream, and sendsbvalues downstream.
Given a named Parser a bmyParser, the simplest way to use
these Proxys together is:
myParsingPipe :: (Proxy p, Monad m, AttoparsecInput a) => Pipe a b m r myParsingPipe = parserInputD >-> parserD myParser
In between these two Proxys, you can place other Proxys to handle
extraordinary situations like parsing failures or limiting input
length. Control.Proxy.Attoparsec.Control exports some useful
Proxys that fit this place. If you skip using any of those, the
default behavior is that of
skipMalformedChunks: to simply
ignore all parsing errors and malformed input, and start parsing new
input as soon as it's available.
parserInputD :: (Monad m, Proxy p) => ParserStatus a -> p () a (ParserStatus a) (ParserSupply a) m rSource
Proxy turning a values flowing downstream into
values to be consumed by a downstream parsing
ParserSupply aProxy.
This Proxy responds with to any Resume aParserStatus value
received from downstream.
parserD :: (Proxy p, Monad m, AttoparsecInput a) => Parser a b -> () -> p (ParserStatus a) (ParserSupply a) () b m rSource
Proxy using the given to repeatedly parse pieces
of Parser a b values flowing downstream into ParserSupply ab values.
When more input is needed, a value reporting the
current parsing status is sent upstream, and in exchange a
ParserStatus a value is expected, containing more input to be
parsed and directives on how to use it (see ParserSupply aParserSupply
documentation).