One of the many things that I admire about Elm as a programming language is the quality of the compiler’s error messages. The “hooks” for providing good error messages are provided by the Error data structure in the elm-tools/parser package. The goal, then, is to make MiniLatex producs as informative and helpful as does Elm. This work is just beginning, but here is a sample of what is possible:
To do this, I’ve added the type LXError Error
to the alternatives that make up the LatexExpression
type used by the parser — a recursive type that represents the abstract syntax tree. The Error
type, which comes from the elm-tools parser, looks like this:
type alias Error = { row : Int , col : Int , source : String , problem : Problem , context : List Context }
It gives enough information so with a suitable dictionary of error data and a bit of logic one can return good error messages. The challenge now is to collect and analyze errors, then wire this kind of intelligence in to MiniLatex.
I’ve implemented only a few error messages as of this writing, but you can experiment with the MiniLatex Demo App.