License | BSD-3-Clause |
---|---|
Maintainer | Jamie Willis, Gigaparsec Maintainers |
Stability | stable |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
This module defines Gigaparsec's default error messages.
The actual ErrorBuilder
class instance is found in
Text.Gigaparsec.Errors.ErrorBuilder.
Synopsis
- from :: Show a => a -> StringBuilder
- intercalate :: Monoid m => m -> [m] -> m
- newtype StringBuilder = StringBuilder (String -> String)
- buildDefault :: StringBuilder -> Maybe StringBuilder -> [StringBuilder] -> String
- vanillaErrorDefault :: Foldable t => Maybe StringBuilder -> Maybe StringBuilder -> t StringBuilder -> [StringBuilder] -> [StringBuilder]
- specialisedErrorDefault :: [StringBuilder] -> [StringBuilder] -> [StringBuilder]
- rawDefault :: String -> String
- namedDefault :: String -> String
- endOfInputDefault :: String
- expectedDefault :: Maybe StringBuilder -> Maybe StringBuilder
- unexpectedDefault :: Maybe String -> Maybe StringBuilder
- disjunct :: Bool -> [String] -> Maybe StringBuilder
- combineMessagesDefault :: Foldable t => t String -> [StringBuilder]
- posDefault :: Word -> Word -> StringBuilder
- lineInfoDefault :: String -> [String] -> [String] -> Word -> Word -> Word -> [StringBuilder]
- toString :: StringBuilder -> String
- blockError :: StringBuilder -> [StringBuilder] -> Int -> StringBuilder
- combineInfoWithLines :: [StringBuilder] -> [StringBuilder] -> [StringBuilder]
- messageDefault :: String -> String
- junct :: Bool -> [String] -> String -> Maybe StringBuilder
- indentAndUnlines :: [StringBuilder] -> Int -> StringBuilder
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.
StringBuilder (String -> String) |
Instances
Monoid StringBuilder Source # | |
Defined in Text.Gigaparsec.Errors.DefaultErrorBuilder mempty :: StringBuilder # mappend :: StringBuilder -> StringBuilder -> StringBuilder # mconcat :: [StringBuilder] -> StringBuilder # | |
Semigroup StringBuilder Source # | |
Defined in Text.Gigaparsec.Errors.DefaultErrorBuilder (<>) :: StringBuilder -> StringBuilder -> StringBuilder # sconcat :: NonEmpty StringBuilder -> StringBuilder # stimes :: Integral b => b -> StringBuilder -> StringBuilder # | |
IsString StringBuilder Source # | |
Defined in Text.Gigaparsec.Errors.DefaultErrorBuilder fromString :: String -> StringBuilder # |
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.