gigaparsec-0.3.0.0: Refreshed parsec-style library for compatibility with Scala parsley
LicenseBSD-3-Clause
MaintainerJamie Willis, Gigaparsec Maintainers
Stabilitystable
Safe HaskellTrustworthy
LanguageHaskell2010

Text.Gigaparsec.Errors.DefaultErrorBuilder

Description

This module defines Gigaparsec's default error messages. The actual ErrorBuilder class instance is found in Text.Gigaparsec.Errors.ErrorBuilder.

Synopsis

Documentation

from :: Show a => a -> StringBuilder Source #

Create a string-builder which starts with the string representation of the given argument.

intercalate :: Monoid m => m -> [m] -> m Source #

newtype StringBuilder Source #

A string-builder is an efficient way of constructing a string through a series of concatenations.

Constructors

StringBuilder (String -> String) 

buildDefault :: StringBuilder -> Maybe StringBuilder -> [StringBuilder] -> String Source #

Forms an error message with blockError, with two spaces of indentation and incorporating the source file and position into the header.

vanillaErrorDefault :: Foldable t => Maybe StringBuilder -> Maybe StringBuilder -> t StringBuilder -> [StringBuilder] -> [StringBuilder] Source #

Forms a vanilla error by combining all the components in sequence, if there is no information other than the lines, "unknown parse error" is used instead.

specialisedErrorDefault :: [StringBuilder] -> [StringBuilder] -> [StringBuilder] Source #

Forms a specialized error by combining all components in sequence, if there are no msgs, then "unknown parse error" is used instead.

rawDefault :: String -> String Source #

Encloses the item in double-quotes.

namedDefault :: String -> String Source #

Returns the given name unchanged.

endOfInputDefault :: String Source #

Simply displays "end of input"

expectedDefault :: Maybe StringBuilder -> Maybe StringBuilder Source #

Adds "expected " before the given alternatives, should they exist.

unexpectedDefault :: Maybe String -> Maybe StringBuilder Source #

Adds "unexpected " before the unexpected item.

disjunct :: Bool -> [String] -> Maybe StringBuilder Source #

Combines the alternatives, separated by commas/semicolons, with the final two separated by "or". If the elements contain a comma, then semicolon is used as the list separator.

combineMessagesDefault :: Foldable t => t String -> [StringBuilder] Source #

Filters out any empty messages and returns the rest.

posDefault :: Word -> Word -> StringBuilder Source #

Pairs the line and column up in the form (line m, column n).

lineInfoDefault :: String -> [String] -> [String] -> Word -> Word -> Word -> [StringBuilder] Source #

Constructs error context by concatenating them together with a "caret line" underneath the focus line, line, where the error occurs.

toString :: StringBuilder -> String Source #

Runs the given string-builder, producing a string.

blockError :: StringBuilder -> [StringBuilder] -> Int -> StringBuilder Source #

Forms an error with the given header followed by a colon, a newline, then the remainder of the lines indented.

combineInfoWithLines :: [StringBuilder] -> [StringBuilder] -> [StringBuilder] Source #

Joins together the given sequences: if the first is empty, then "unknown parse error" is prepended onto lines instead.

messageDefault :: String -> String Source #

Returns the given message unchanged.

junct :: Bool -> [String] -> String -> Maybe StringBuilder Source #

Combines the alternatives, separated by commas/semicolons, with the final two separated by "or". An Oxford comma is added if there are more than two elements, as this helps prevent ambiguity in the list. If the elements contain a comma, then semicolon is used as the list separator.

indentAndUnlines :: [StringBuilder] -> Int -> StringBuilder Source #

Indents and concatenates the given lines by the given depth.