jschomay / elm-narrative-engine / NarrativeEngine.Syntax.Helpers

A utility module supporting the parsers.


type alias ParseErrors =
List ( String
, String 
}

Parse errors are a list of an identifier (which usually includes the raw source string) and a string representation of the raw parse errors.

parseErrorsView : ParseErrors -> Html msg

A helper to show all parse errors. You should identify all possible parse errors as soon as possible, ideally at the top elm Program level, and show this view if you have errors.

The tuple is a string identifying the source of the error, and the atual error string iteself.

Misc

deadEndsToString : List Parser.DeadEnd -> String

A simple way to show errors. Borrowed from https://github.com/elm/parser/pull/16

notEmpty : String -> Parser String

A string parser that fails if the string is empty and succeeds otherwise.

parseMultiple : (String -> Result String a) -> List String -> Result String (List a)

Generic helper to parse a list against a supplied parse function. Will be Err if any items fail to parse, or an Ok of the list of parsed results. Useful for parsing a rule's conditions and changes for example.