ta0kira / zeolite

Zeolite is a statically-typed, general-purpose programming language.
Apache License 2.0
18 stars 0 forks source link

Use `megaparsec` instead of `parsec` to make structured errors possible. #119

Closed ta0kira closed 3 years ago

ta0kira commented 3 years ago

Even though #114 made it possible to use the same single-error syntax that the rest of the project uses, ParsecT (from parsec) doesn't allow direct access to the Monad it transforms

ParsecT (from megaparsec) allows a custom error type. This won't allow the fail-fast semantics of transforming an error-handling Monad, but ParsecT could be used with CompilerMessage as the error type and Identity as the Monad. Then an instance of ErrorContextM (recently split off from CompileErrorM) could be created for ParsecT CompilerMessage s Identity so that ??> (etc.) can be used during parsing.

The downside is that it adds a few more transitive dependencies, although they don't seem excessive.