miniBill/elm-parser-error-extra/1.0.0

NOTE: the latest version is 1.0.1

Parser.Error

Output out
-> Extract inner problem
-> String
-> List (DeadEnd inner problem)
-> List out

Render a list of DeadEnds.

The String is the input to the parser.

This returns a list of "pieces", look at the README for examples of how to combine them.

type alias Output out =
{ text : String -> out
, formatCaret : out -> out
, newline : out
, formatContext : out -> out
, linesOfExtraContext : Int
}

Describes how to output the various parts of the error message.

type alias DeadEnd inner problem =
{ inner | row : Int, col : Int, problem : problem }

A type which encompasses both Parser.DeadEnd and Parser.Advanced.DeadEnd.

Extraction

type alias Extract inner problem =
{ contextStack :
DeadEnd inner problem
-> List
{ row : Int
, col : Int
, context : String
}
, problemToString : problem -> Expected
}

Describes how to get the context stack from a DeadEnd and how to extract expectations information from a problem.

You can usually use forParser and forParserAdvanced.

forParser : Extract {} Problem

And Extract for the basic Parser.DeadEnd.

Extract
{ contextStack :
List
{ row : Int
, col : Int
, context : String
}
}
Problem

And Extract for Parser.Advanced.DeadEnd when the problem is a Parser.Problem.

= Expected String
| Other String

A problem is often of the form "expected something". This type is used to group those together.

Utilities

Categorize a Problem in whether it's "expected something" or something else.