attoparsec-0.12.1.2: Fast combinator parsing for bytestrings and text

Portability | unknown
Stability | experimental
Maintainer | bos@serpentine.com
Safe Haskell | None

Data.Attoparsec.Types

Description

Simple, efficient parser combinators for strings, loosely based on the Parsec library.

Synopsis

- data Parser i a
- data IResult i r
  - = Fail i [String] String
  - | Partial (i -> IResult i r)
  - | Done i r
- class Monoid c => Chunk c where
  - chunkElemToChar :: c -> ChunkElem c -> Char

# Documentation

data Parser i a

The core parser type. This is parameterised over the types `i` of string being processed and `t` of internal state representation.

This type is an instance of the following classes:

- `Monad`, where `fail` throws an exception (i.e. fails) with an error message.
- `Functor` and `Applicative`, which follow the usual definitions.
- `MonadPlus`, where `mzero` fails (with no error message) and `mplus` executes the right-hand parser if the left-hand one fails. When the parser on the right executes, the input is reset to the same state as the parser on the left started with. (In other words, attoparsec is a backtracking parser that supports arbitrary lookahead.)
- `Alternative`, which follows `MonadPlus`.

Instances

Monad (Parser i) |
Functor (Parser i) |
MonadPlus (Parser i) |
~ * a ByteString => IsString (Parser a) |
~ * a Text => IsString (Parser a) |
Applicative (Parser i) |
Alternative (Parser i) |
Monoid (Parser i a) |

data IResult i r

The result of a parse. This is parameterised over the type `i` of string that was processed.

This type is an instance of `Functor`, where `fmap` transforms the value in a `Done` result.

Constructors

Fail i [String] String | The parse failed. The `i` parameter 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.
Partial (i -> IResult i r) | Supply this continuation with more input so that the parser can resume. To indicate that no more input is available, pass an empty string to the continuation. __Note__: if you get a `Partial` result, do not call its continuation more than once.
Done i r | The parse succeeded. The `i` parameter is the input that had not yet been consumed (if any) when the parse succeeded.

Instances

Functor (IResult i) |
(Show i, Show r) => Show (IResult i r) |
(NFData i, NFData r) => NFData (IResult i r) |

class Monoid c => Chunk c where

A common interface for input chunks.

Methods

chunkElemToChar :: c -> ChunkElem c -> Char

Map an element to the corresponding character. The first argument is ignored.

Instances

Chunk ByteString |
Chunk Text |