Is it possible to stop typeclass resolution prematurely from a Hint Extern? As is expected, simply fail
ing in the hint will make the resolution backtrack and try other things; I'm wondering if it's possible to completely abort the resolution?
Alternatively, if that's not possible, I'm wondering if there's a "well-known" pattern for handling failure and returning error messages for prolog-like programs written using typeclass resolution -- similar to a "result" type
Seems to be an open issue https://github.com/coq/coq/issues/4776
I recall that Hint Cut
exists and is relevant (it's in the manual), but I also did not understand its semantics or use it (or see anybody using it). IIRC, it performs Prolog-like cuts under some conditions.
(which you can specify)
No it does not perform prolog cuts. What does is Hint Extern If
but the development is stalled (there is a PR by Matthieu somewhere)
Anyway prolog fail
is not implemented either. I strongly recommand any non trivial logic program for Coq to be implemted in coq-elpi for now, which is the only real meta logic programming language available for coq as of today afaik
Armaël Guéneau said:
Alternatively, if that's not possible, I'm wondering if there's a "well-known" pattern for handling failure and returning error messages for prolog-like programs written using typeclass resolution -- similar to a "result" type
FTR I tried anything I could think of, the best result I got is the propagation of an error message with flag parameters for the class, but it does not always work....
IIRC Ltac2 has a fatal error API. You should try that one.
I've seen it in a demo, but I could not point you to the API, sorry.
You'll have to dig yourself ;-)
Last updated: Oct 01 2023 at 18:01 UTC