License | BSD-3-Clause |
---|---|
Maintainer | Jamie Willis, Gigaparsec Maintainers |
Stability | stable |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
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
- blockError :: StringBuilder -> [StringBuilder] -> Int -> StringBuilder
- buildDefault :: StringBuilder -> Maybe StringBuilder -> [StringBuilder] -> String
- combineInfoWithLines :: [StringBuilder] -> [StringBuilder] -> [StringBuilder]
- combineMessagesDefault :: Foldable t => t String -> [StringBuilder]
- disjunct :: Bool -> [String] -> Maybe StringBuilder
- endOfInputDefault :: String
- expectedDefault :: Maybe StringBuilder -> Maybe StringBuilder
- from :: Show a => a -> StringBuilder
- indentAndUnlines :: [StringBuilder] -> Int -> StringBuilder
- intercalate :: Monoid m => m -> [m] -> m
- junct :: Bool -> [String] -> String -> Maybe StringBuilder
- lineInfoDefault :: String -> [String] -> [String] -> Word -> Word -> Word -> [StringBuilder]
- messageDefault :: String -> String
- namedDefault :: String -> String
- posDefault :: Word -> Word -> StringBuilder
- rawDefault :: String -> String
- specialisedErrorDefault :: [StringBuilder] -> [StringBuilder] -> [StringBuilder]
- toString :: StringBuilder -> String
- unexpectedDefault :: Maybe String -> Maybe StringBuilder
- vanillaErrorDefault :: Foldable t => Maybe StringBuilder -> Maybe StringBuilder -> t StringBuilder -> [StringBuilder] -> [StringBuilder]
- newtype StringBuilder = StringBuilder (String -> String)
Documentation
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.
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.
combineInfoWithLines :: [StringBuilder] -> [StringBuilder] -> [StringBuilder] Source #
Joins together the given sequences: if the first is empty, then "unknown parse error" is prepended onto lines instead.
combineMessagesDefault :: Foldable t => t String -> [StringBuilder] Source #
Filters out any empty messages and returns the rest.
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.
endOfInputDefault :: String Source #
Simply displays "end of input"
expectedDefault :: Maybe StringBuilder -> Maybe StringBuilder Source #
Adds "expected " before the given alternatives, should they exist.
from :: Show a => a -> StringBuilder Source #
Create a string-builder which starts with the string representation of the given argument.
indentAndUnlines :: [StringBuilder] -> Int -> StringBuilder Source #
Indents and concatenates the given lines by the given depth.
intercalate :: Monoid m => m -> [m] -> m Source #
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.
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.
messageDefault :: String -> String Source #
Returns the given message unchanged.
namedDefault :: String -> String Source #
Returns the given name unchanged.
posDefault :: Word -> Word -> StringBuilder Source #
Pairs the line and column up in the form (line m, column n)
.
rawDefault :: String -> String Source #
Encloses the item in double-quotes.
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.
toString :: StringBuilder -> String Source #
Runs the given string-builder, producing a string.
unexpectedDefault :: Maybe String -> Maybe StringBuilder Source #
Adds "unexpected " before the unexpected item.
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.
newtype StringBuilder Source #
A string-builder is an efficient way of constructing a string through a series of concatenations.
Constructors
StringBuilder (String -> String) |
Instances
Monoid StringBuilder Source # | |
Defined in Text.Gigaparsec.Errors.DefaultErrorBuilder Methods mempty :: StringBuilder # mappend :: StringBuilder -> StringBuilder -> StringBuilder # mconcat :: [StringBuilder] -> StringBuilder # | |
Semigroup StringBuilder Source # | |
Defined in Text.Gigaparsec.Errors.DefaultErrorBuilder Methods (<>) :: StringBuilder -> StringBuilder -> StringBuilder # sconcat :: NonEmpty StringBuilder -> StringBuilder # stimes :: Integral b => b -> StringBuilder -> StringBuilder # | |
IsString StringBuilder Source # | |
Defined in Text.Gigaparsec.Errors.DefaultErrorBuilder Methods fromString :: String -> StringBuilder # |