pipes-attoparsec-0.1.0.1: Utilities to convert an Attoparsec parser into a pipe Pipe.

Safe HaskellNone

Control.Proxy.Attoparsec.Control

Description

This module exports some useful Proxys that act upon ParserStatus values received from downstream.

Synopsis

Documentation

skipMalformedChunks :: (Monad m, Proxy p, AttoparsecInput a) => ParserStatus a -> p (ParserStatus a) (ParserSupply a) (ParserStatus a) (ParserSupply a) m rSource

If a downstream parsing Proxy reports a parser failure, skip the whole input chunk being processed, including any left-overs, and start processing new input as soon as it's available.

Useful when the input found in a single ParserSupply a is supposed to be well-formed, so it can be safely skipped if it is not.

retryLeftovers :: (Monad m, Proxy p, AttoparsecInput a) => ParserStatus a -> p (ParserStatus a) (ParserSupply a) (ParserStatus a) (ParserSupply a) m rSource

If a downstream parsing Proxy reports a parsing failure, then keep retrying with any left-over input, skipping individual bits each time. If there are no left-overs, then more input is requestsd form upstream.

throwParsingErrors :: (Monad m, Proxy p, AttoparsecInput a) => ParserStatus a -> EitherP BadInput p (ParserStatus a) (ParserSupply a) (ParserStatus a) (ParserSupply a) m rSource

If a downstream parsing Proxy reports a parser failure, then throw a MalformedInput error in the EitherP proxy transformer.

limitInputLength :: (Monad m, Proxy p, AttoparsecInput a) => Int -> ParserStatus a -> EitherP BadInput p (ParserStatus a) (ParserSupply a) (ParserStatus a) (ParserSupply a) m rSource

If a downstream parsing Proxy doesn't produce a value after having consumed input of at least the given length, then throw an InputTooLong error in the EitherP proxy transformer.