| License | BSD-3-Clause | 
|---|---|
| Maintainer | Jamie Willis, Gigaparsec Maintainers | 
| Stability | experimental | 
| Safe Haskell | Safe | 
| Language | Haskell2010 | 
Text.Gigaparsec.Errors.ErrorGen
Description
This module can be used to generate hand-tuned error messages without using monadic bind.
Synopsis
- data ErrorGen a- = SpecializedGen { - messages :: a -> [String]
- adjustWidth :: a -> Word -> Word
 
- | VanillaGen { - unexpected :: a -> UnexpectedItem
- reason :: a -> Maybe String
- adjustWidth :: a -> Word -> Word
 
 
- = SpecializedGen { 
- data UnexpectedItem
- vanillaGen :: ErrorGen a
- specializedGen :: ErrorGen a
- asFail :: ErrorGen a -> Parsec (a, Word) -> Parsec b
- asSelect :: ErrorGen a -> Parsec (Either (a, Word) b) -> Parsec b
- asErr :: ErrorGen a -> a -> Word -> Parsec b
Documentation
Error Generators
This type describes special primitives that can use the results of a previous parser 
to form and raise an error message. 
This is not something that is normally possible with raw combinators, without using (>>=), 
which is expensive.
Primarily, these are designed to be used with 
filterSWith/verifiedWith/preventWith
but can be used in other parsers as well. 
Constructors
| SpecializedGen | An error generator for Specialized errors, which can tune the freeform messages of the error. | 
| Fields 
 | |
| VanillaGen | An error generator for Vanilla errors, which can tune the unexpected message and a generated reason. | 
| Fields 
 | |
data UnexpectedItem Source #
This type describes how to form the unexpected component of a vanilla error message from a VanillaGen.
This includes the different sorts of 'unexpected item' messages that may occur; whether to display the expected characters, a name for the expected expression, or not to display at all.
Blank Generators
vanillaGen :: ErrorGen a Source #
A blank Vanilla error generator, which does not affect the unexpected message or reason.
specializedGen :: ErrorGen a Source #
The default Specialized error generator, which does not affect the error message.
Error Generating Combinators
These combinators create parsers that fail or raise errors with messages desribed by a given ErrorGen.
Arguments
| :: ErrorGen a | 
 | 
| -> Parsec (a, Word) | 
 | 
| -> Parsec b | A parser that unconditionally fails with a message described by  | 
This combinator takes a given parser p and unconditionally fails with a message based on p's results.
Arguments
| :: ErrorGen a | 
 | 
| -> Parsec (Either (a, Word) b) | 
 | 
| -> Parsec b | A parser that fails if  | 
This combinator takes a given parser p and, if p returns an a, 
fails with a message based on this result.
Arguments
| :: ErrorGen a | 
 | 
| -> a | 
 | 
| -> Word | The width of the parsed result,  | 
| -> Parsec b | A parser that unconditionally raises an error described by  | 
Given a parser result and its width, raise an error according to the given error generator.