Open david-christiansen opened 9 years ago
Once the new tactics are working, it might also be worth looking into whether an error rewriter should be in the new tactics monad instead of Maybe
, because then it could do things like suggest alternative names based on the global context.
Idris's error message objects carry with them the context in which they arose. This allows lexically bound variables to be highlighted as such in displayed errors. However, that information is lost following error rewriters, so some variables show up without highlighting.
I see two potential solutions:
I'm inclined towards option 2. Option 1 is more flexible and allows DSL authors to "lie" about the context in which the errors arose, which might in fact give a better message. However, it's also tedious, requiring every single rewriter to do the right thing with the context extracted from the reflected errors. I think that, in the vast majority of cases, we actually just want to propagate the context.
I suppose there's a third option, which is to completely decouple the reflection API from the internal compiler error representation (this is really a more radical version of Option 2). Then, error rewriters could return something like:
when they rewrite.
Limiting the collection of errors that are rewritable to unification errors, proof search failures, and conversion failures (perhaps one or two more), with some things like recoverability of unification errors stripped form the representation, could also give us a more coherent, testable API as well as lessen the burden of changing the internal errors (because never-used error reflection routines would not need updating except in a few cases).