Skip to content

Commit 67e3e89

Browse files
committed
wip
1 parent ef304b5 commit 67e3e89

File tree

7 files changed

+40
-11
lines changed

7 files changed

+40
-11
lines changed

.nix/coq-overlays/coq-elpi/default.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ with builtins; with lib; let
99
{ case = "8.15"; out = { version = "1.16.5"; };}
1010
{ case = "8.16"; out = { version = "1.16.5"; };}
1111
] {} );
12+
dot-merlin-reader = coq.ocamlPackages.dot-merlin-reader;
13+
dune = coq.ocamlPackages.dune_3;
1214
in mkCoqDerivation {
1315
pname = "elpi";
1416
repo = "coq-elpi";
@@ -53,7 +55,7 @@ in mkCoqDerivation {
5355
releaseRev = v: "v${v}";
5456

5557
mlPlugin = true;
56-
propagatedBuildInputs = [ elpi ];
58+
propagatedBuildInputs = [ elpi dot-merlin-reader dune ];
5759

5860
meta = {
5961
description = "Coq plugin embedding ELPI.";

.nix/ocaml-overlays/elpi/default.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{ lib
22
, buildDunePackage, camlp5
33
, ocaml
4+
, ocaml-lsp
45
, menhir, menhirLib
56
, stdlib-shims
67
, re, perl, ncurses
@@ -34,7 +35,7 @@ buildDunePackage rec {
3435
buildInputs = [ perl ncurses ]
3536
++ optional (versionAtLeast version "1.15" || version == "dev") menhir;
3637

37-
propagatedBuildInputs = [ re stdlib-shims ]
38+
propagatedBuildInputs = [ re stdlib-shims ocaml-lsp ]
3839
++ (if versionAtLeast version "1.15" || version == "dev"
3940
then [ menhirLib ]
4041
else [ camlp5 ] )

coq-builtin.elpi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,11 @@ typeabbrev opaque? bool. macro @opaque! :- tt. macro @transparent! :- ff.
354354
macro @global! :- get-option "coq:locality" "global".
355355
macro @local! :- get-option "coq:locality" "local".
356356

357+
macro @keep-alg-univs! :-
358+
get-option "coq:algunivs" "keep-algunivs".
359+
macro @purge-alg-univs! :-
360+
get-option "coq:algunivs" "purge-algunivs".
361+
357362
macro @primitive! :- get-option "coq:primitive" tt. % primitive records
358363
macro @nonuniform! :- get-option "coq:nonuniform" tt. % coercions
359364
macro @reversible! :- get-option "coq:reversible" tt. % coercions

elpi/coq-HOAS.elpi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,11 @@ typeabbrev opaque? bool. macro @opaque! :- tt. macro @transparent! :- ff.
339339
macro @global! :- get-option "coq:locality" "global".
340340
macro @local! :- get-option "coq:locality" "local".
341341

342+
macro @keep-alg-univs! :-
343+
get-option "coq:algunivs" "keep-algunivs".
344+
macro @purge-alg-univs! :-
345+
get-option "coq:algunivs" "purge-algunivs".
346+
342347
macro @primitive! :- get-option "coq:primitive" tt. % primitive records
343348
macro @nonuniform! :- get-option "coq:nonuniform" tt. % coercions
344349
macro @reversible! :- get-option "coq:reversible" tt. % coercions

src/coq_elpi_HOAS.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ type options = {
344344
reversible : bool option;
345345
keepunivs : bool option;
346346
redflags : CClosure.RedFlags.reds option;
347+
algunivs : bool option;
347348
}
348349

349350
let default_options () = {
@@ -363,6 +364,7 @@ let default_options () = {
363364
reversible = None;
364365
keepunivs = None;
365366
redflags = None;
367+
algunivs = None;
366368
}
367369

368370
type 'a coq_context = {
@@ -1105,6 +1107,12 @@ let get_options ~depth hyps state =
11051107
let _, rd, gl = reduction_flags.Elpi.API.Conversion.readback ~depth state t in
11061108
assert (gl = []);
11071109
Some rd in
1110+
let keeping_algebraic_universes s =
1111+
if s = Some "default" then None
1112+
else if s = Some "keep-alguniv" then Some true
1113+
else if s = Some "purge-alguniv" then Some false
1114+
else if s = None then None
1115+
else err Pp.(str"Unknown algebraic universes attribute: " ++ str (Option.get s)) in
11081116
{
11091117
hoas_holes =
11101118
begin match get_bool_option "HOAS:holes" with
@@ -1126,6 +1134,7 @@ let get_options ~depth hyps state =
11261134
reversible = get_bool_option "coq:reversible";
11271135
keepunivs = get_bool_option "coq:keepunivs";
11281136
redflags = get_redflags_option ();
1137+
algunivs = keeping_algebraic_universes @@ get_string_option "coq:algunivs";
11291138
}
11301139

11311140
let mk_coq_context ~options state =

src/coq_elpi_HOAS.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type options = {
4747
reversible : bool option;
4848
keepunivs : bool option;
4949
redflags : CClosure.RedFlags.reds option;
50+
algunivs : bool option;
5051
}
5152

5253
type 'a coq_context = {

src/coq_elpi_builtins.ml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2173,29 +2173,35 @@ phase unnecessary.|};
21732173
MLCode(Pred("coq.sort.leq",
21742174
InOut(B.ioarg_flex sort, "S1",
21752175
InOut(B.ioarg_flex sort, "S2",
2176-
Full(unit_ctx, "constrains S1 <= S2"))),
2177-
(fun u1 u2 ~depth _ _ state ->
2176+
Full(global, "constrains S1 <= S2"))),
2177+
(fun u1 u2 ~depth { options } _ -> on_global_state "coq.sort.leq"
2178+
(fun state ->
21782179
match u1, u2 with
21792180
| Data u1, Data u2 ->
21802181
if Sorts.equal u1 u2 then state, !: u1 +! u2,[]
21812182
else
2182-
(* let state, u2 = purge_algebraic_univs_sort state (EConstr.ESorts.make u2) in *)
2183-
add_universe_constraint state (constraint_leq u1 u2), !: u1 +! u2,[]
2184-
| _ -> err Pp.(str"coq.sort.leq: called with _ as argument"))),
2183+
let state, u2 = if true (* options.algunivs != Some true *)
2184+
then purge_algebraic_univs_sort state (EConstr.ESorts.make u2)
2185+
else state, u2 in
2186+
add_universe_constraint state (constraint_leq u1 u2), !: u1 +! u2,[]
2187+
| _ -> err Pp.(str"coq.sort.leq: called with _ as argument")))),
21852188
DocAbove);
21862189

21872190
MLCode(Pred("coq.sort.eq",
21882191
InOut(B.ioarg_flex sort, "S1",
21892192
InOut(B.ioarg_flex sort, "S2",
2190-
Full(unit_ctx, "constrains S1 = S2"))),
2191-
(fun u1 u2 ~depth _ _ state ->
2193+
Full(global, "constrains S1 = S2"))),
2194+
(fun u1 u2 ~depth { options } _ -> on_global_state "coq.sort.eq"
2195+
(fun state ->
21922196
match u1, u2 with
21932197
| Data u1, Data u2 ->
21942198
if Sorts.equal u1 u2 then state, !: u1 +! u2,[]
21952199
else
2196-
(* let state, u2 = purge_algebraic_univs_sort state (EConstr.ESorts.make u2) in *)
2200+
let state, u2 = if true (* options.algunivs != Some true *)
2201+
then purge_algebraic_univs_sort state (EConstr.ESorts.make u2)
2202+
else state, u2 in
21972203
add_universe_constraint state (constraint_eq u1 u2), !: u1 +! u2, []
2198-
| _ -> err Pp.(str"coq.sort.eq: called with _ as argument"))),
2204+
| _ -> err Pp.(str"coq.sort.eq: called with _ as argument")))),
21992205
DocAbove);
22002206

22012207
MLCode(Pred("coq.sort.sup",

0 commit comments

Comments
 (0)