attoparsec-0.13.2.1: Fast combinator parsing for bytestrings and text

CopyrightBryan O'Sullivan 2007-2015
LicenseBSD3
Maintainerbos@serpentine.com
Stabilityexperimental
Portabilityunknown
Safe HaskellTrustworthy
LanguageHaskell98

Data.Attoparsec.Text.Lazy

Contents

Description

Simple, efficient combinator parsing that can consume lazy Text strings, loosely based on the Parsec library.

This is essentially the same code as in the Text module, only with a parse function that can consume a lazy Text incrementally, and a Result type that does not allow more input to be fed in. Think of this as suitable for use with a lazily read file, e.g. via readFile or hGetContents.

Note: The various parser functions and combinators such as string still expect strict Text parameters, and return strict Text results. Behind the scenes, strict Text values are still used internally to store parser input and manipulate it efficiently.

Synopsis

Documentation

data Result r Source #

The result of a parse.

Constructors

Fail Text [String] String

The parse failed. The Text is the input that had not yet been consumed when the failure occurred. The [String] is a list of contexts in which the error occurred. The String is the message describing the error, if any.

Done Text r

The parse succeeded. The Text is the input that had not yet been consumed (if any) when the parse succeeded.

Instances

Functor Result Source # 

Methods

fmap :: (a -> b) -> Result a -> Result b #

(<$) :: a -> Result b -> Result a #

Show r => Show (Result r) Source # 

Methods

showsPrec :: Int -> Result r -> ShowS #

show :: Result r -> String #

showList :: [Result r] -> ShowS #

NFData r => NFData (Result r) Source # 

Methods

rnf :: Result r -> () #

Running parsers

parse :: Parser a -> Text -> Result a Source #

Run a parser and return its result.

parseTest :: Show a => Parser a -> Text -> IO () Source #

Run a parser and print its result to standard output.

Result conversion

maybeResult :: Result r -> Maybe r Source #

Convert a Result value to a Maybe value.

eitherResult :: Result r -> Either String r Source #

Convert a Result value to an Either value.