Debian Codegraph @

elpi/coq-elpi-checker.elpi

raw
1 /* rocq-elpi: Coq terms as the object language of elpi */
2 /* license: GNU Lesser General Public License Version 2.1 or later */
3 /* ------------------------------------------------------------------------- */
4
5 % redirect to Coq type checking messages
6
7 :before "default-typechecking-error"
8 error [] _ :- !.
9 :before "default-typechecking-error"
10 error [pr L M] tt :- !, coq.error L M.
11 :before "default-typechecking-error"
12 error [pr L M|MS] tt :- Msgs = [pr L M|MS], all-same-loc L Msgs, !, coq.error L "At least one of the following errors holds:" {error-concat-noloc Msgs}.
13 :before "default-typechecking-error"
14 error Msgs tt :- !, coq.error "At least one of the following errors holds:" {error-concat Msgs}.
15
16 func error-concat list string -> string.
17 error-concat L R :- std.string.concat "\n" {std.map L error-pp-wloc} R.
18 func error-concat-noloc list string -> string.
19 error-concat-noloc L R :- std.string.concat "\n" {std.map L error-pp-noloc} R.
20
21 func error-pp-wloc pair loc string -> string.
22 error-pp-wloc (pr L S) R :- R is {std.any->string L} ^ " " ^ S.
23 func error-pp-noloc pair loc string -> string.
24 error-pp-noloc (pr _ S) R :- R is "- " ^ S.
25
26 func all-same-loc loc, list (pair loc string) ->.
27 all-same-loc L XS :- std.forall XS (x\sigma s\x = pr L s).
28
29 :before "default-typechecking-warning"
30 warning L M :- !, coq.warning "elpi" "elpi.typecheck" L M.