conduit-extra-1.3.5: Batteries included conduit: adapters for common libraries.
Copyright2011 Michael Snoyman 2010 John Millikin
LicenseMIT
Safe HaskellNone
LanguageHaskell98

Data.Conduit.Attoparsec

Description

Consume attoparsec parsers via conduit.

This code was taken from attoparsec-enumerator and adapted for conduits.

Synopsis

Sink

sinkParser :: (AttoparsecInput a, MonadThrow m) => Parser a b -> ConduitT a o m b #

Convert an Attoparsec Parser into a Sink. The parser will be streamed bytes until it returns Done or Fail.

If parsing fails, a ParseError will be thrown with throwM.

Since 0.5.0

sinkParserEither :: (AttoparsecInput a, Monad m) => Parser a b -> ConduitT a o m (Either ParseError b) #

Same as sinkParser, but we return an Either type instead of raising an exception.

Since 1.1.5

Conduit

conduitParser :: (AttoparsecInput a, MonadThrow m) => Parser a b -> ConduitT a (PositionRange, b) m () #

Consume a stream of parsed tokens, returning both the token and the position it appears at. This function will raise a ParseError on bad input.

Since 0.5.0

conduitParserEither :: (Monad m, AttoparsecInput a) => Parser a b -> ConduitT a (Either ParseError (PositionRange, b)) m () #

Same as conduitParser, but we return an Either type instead of raising an exception.

Types

data ParseError #

The context and message from a Fail value.

data Position #

Constructors

Position 

Fields

Instances

Instances details
Eq Position # 
Instance details

Defined in Data.Conduit.Attoparsec

Ord Position # 
Instance details

Defined in Data.Conduit.Attoparsec

Show Position # 
Instance details

Defined in Data.Conduit.Attoparsec

Classes

class AttoparsecInput a #

A class of types which may be consumed by an Attoparsec parser.

Minimal complete definition

parseA, feedA, empty, isNull, getLinesCols, stripFromEnd