Skip to content

Commit 8eaf7ef

Browse files
authored
Merge branch 'master' into attlabel
2 parents a47ba54 + 475ac11 commit 8eaf7ef

File tree

5 files changed

+41
-9
lines changed

5 files changed

+41
-9
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### API
66
- New `coq.parse-attributes` support for the `attlabel` specification,
77
see `coq-lib-common.elpi` for its documentation.
8+
- New `coq.goal->pp`
89

910
## [2.0.2] - 01/02/2024
1011

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,13 @@ In order to load Coq-Elpi use `From elpi Require Import elpi`.
181181
It understands the `#[phase]` attribute, see [synterp-vs-interp](README.md#separation-of-parsing-from-execution-of-vernacular-commands).
182182
- `Elpi Program <qname> <code>` lower level primitive letting one crate a
183183
command/tactic with a custom preamble `<code>`.
184-
185-
- `Elpi Accumulate [<qname>] [<code>|File <filename> From <loadpath>|Db <dbname>]`
184+
- `From some.load.path Extra Dependency "filename" as <fname>`.
185+
- `Elpi Accumulate [<qname>] [<code>|File <fname>|Db <dbname>]`
186186
adds code to the current program (or `<qname>` if specified).
187187
The code can be verbatim, from a file or a Db.
188188
It understands the `#[skip="rex"]` and `#[only="rex"]` which make the command
189189
a no op if the Coq version is matched (or not) by the given regular expression.
190-
File names are relative to the directory mapped to `<loadpath>`; if more than
191-
one such directory exists, the `<filename>` must exists only once.
190+
File names `<fname>` must have been previously declared with the above command.
192191
It understands the `#[phase]` attribute, see [synterp-vs-interp](README.md#separation-of-parsing-from-execution-of-vernacular-commands)
193192
- `Elpi Typecheck [<qname>]` typechecks the current program (or `<qname>` if
194193
specified).

coq-builtin.elpi

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,6 +1691,16 @@ external pred coq.term->string i:term, o:string.
16911691
% - @holes! (default: false, prints evars as _)
16921692
external pred coq.term->pp i:term, o:coq.pp.
16931693

1694+
% [coq.goal->pp G B] prints a goal G to a pp.t B using Coq's pretty
1695+
% printer"
1696+
% Supported attributes:
1697+
% - @ppall! (default: false, prints all details)
1698+
% - @ppmost! (default: false, prints most details)
1699+
% - @pplevel! (default: _, prints parentheses to reach that level, 200 =
1700+
% off)
1701+
% - @holes! (default: false, prints evars as _)
1702+
external pred coq.goal->pp i:goal, o:coq.pp.
1703+
16941704
% -- Extra Dependencies -----------------------------------------------
16951705

16961706
% [coq.extra-dep Identifier FileName] Resolve the file name of an extra

src/coq_elpi_builtins.ml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3830,6 +3830,30 @@ Supported attributes:
38303830
state, !: s, [])),
38313831
DocAbove);
38323832

3833+
MLCode(Pred("coq.goal->pp",
3834+
CIn(goal,"G",
3835+
Out(ppboxes, "B",
3836+
Full(raw_ctx, {|prints a goal G to a pp.t B using Coq's pretty printer"
3837+
Supported attributes:
3838+
- @ppall! (default: false, prints all details)
3839+
- @ppmost! (default: false, prints most details)
3840+
- @pplevel! (default: _, prints parentheses to reach that level, 200 = off)
3841+
- @holes! (default: false, prints evars as _)|}))),
3842+
(fun (proof_context,evar,args) _ ~depth _ _ state ->
3843+
let sigma = get_sigma state in
3844+
let pr_named_context_of env sigma =
3845+
let make_decl_list env d pps = Printer.pr_named_decl env sigma d :: pps in
3846+
let psl = List.rev (Environ.fold_named_context make_decl_list env ~init:[]) in
3847+
Pp.(v 0 (prlist_with_sep (fun _ -> ws 2) (fun x -> x) psl)) in
3848+
let s = Pp.(repr @@ with_pp_options proof_context.options.pp (fun () ->
3849+
v 0 @@
3850+
pr_named_context_of proof_context.env sigma ++ cut () ++
3851+
str "======================" ++ cut () ++
3852+
Printer.pr_econstr_env proof_context.env sigma
3853+
Evd.(evar_concl @@ find_undefined sigma evar))) in
3854+
state, !: s, [])),
3855+
DocAbove);
3856+
38333857
LPDoc "-- Extra Dependencies -----------------------------------------------";
38343858

38353859
MLCode(Pred("coq.extra-dep",

tests/test_tactic.v

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@ Elpi Print foobar.
2626
Elpi Tactic print_goal.
2727
Elpi Accumulate lp:{{
2828

29-
solve (goal L _ T _ As as G) [seal G] :-
29+
solve (goal _ _ _ _ _ as G) [seal G] :-
3030
print_constraints,
31-
coq.say "Goal: ", coq.say As, coq.say "\n",
32-
coq.say L,
33-
coq.say "------------",
34-
coq.say T {coq.term->string T}.
31+
coq.say "Goal: \n",
32+
coq.say {coq.pp->string {coq.goal->pp G} }.
3533

3634
}}.
3735

0 commit comments

Comments
 (0)