Skip to content

Commit b3f57f6

Browse files
author
Jan-Oliver Kaiser
committed
Add @no-coercion! option and macro
1 parent e427ff0 commit b3f57f6

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

builtin-doc/coq-builtin.elpi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ macro @keep-alg-univs! :- get-option "coq:keepalgunivs" tt.
480480
macro @primitive! :- get-option "coq:primitive" tt. % primitive records
481481
macro @reversible! :- get-option "coq:reversible" tt. % coercions
482482
macro @no-tc! :- get-option "coq:no_tc" tt. % skip typeclass inference
483+
macro @no-coercion! :- get-option "coq:no_coercion" tt. % ignore coercions during pretyping
483484

484485
macro @uinstance! I :- get-option "coq:uinstance" I. % universe instance
485486

elpi/coq-HOAS.elpi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ macro @keep-alg-univs! :- get-option "coq:keepalgunivs" tt.
308308
macro @primitive! :- get-option "coq:primitive" tt. % primitive records
309309
macro @reversible! :- get-option "coq:reversible" tt. % coercions
310310
macro @no-tc! :- get-option "coq:no_tc" tt. % skip typeclass inference
311+
macro @no-coercion! :- get-option "coq:no_coercion" tt. % ignore coercions during pretyping
311312

312313
macro @uinstance! I :- get-option "coq:uinstance" I. % universe instance
313314

src/rocq_elpi_HOAS.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ type options = {
311311
keepunivs : bool option;
312312
redflags : RedFlags.reds option;
313313
no_tc: bool option;
314+
no_coercion: bool option;
314315
algunivs : bool option;
315316
}
316317
let default_options () = {
@@ -330,15 +331,16 @@ let default_options () = {
330331
keepunivs = None;
331332
redflags = None;
332333
no_tc = None;
334+
no_coercion = None;
333335
algunivs = None;
334336
}
335337
let make_options ~hoas_holes ~local ~warn ~depr ~primitive ~failsafe ~ppwidth
336338
~pp ~pplevel ~using ~inline ~uinstance ~universe_decl ~reversible ~keepunivs
337-
~redflags ~no_tc ~algunivs =
339+
~redflags ~no_tc ~no_coercion ~algunivs =
338340
let user_warns = Some UserWarn.{ depr; warn } in
339341
{ hoas_holes; local; user_warns; primitive; failsafe; ppwidth; pp;
340342
pplevel; using; inline; uinstance; universe_decl; reversible; keepunivs;
341-
redflags; no_tc; algunivs; }
343+
redflags; no_tc; no_coercion; algunivs; }
342344
let make_warn = UserWarn.make_warn
343345

344346
type 'a coq_context = {
@@ -1314,12 +1316,13 @@ let get_options ~depth hyps state =
13141316
let universe_decl = get_universe_decl () in
13151317
let reversible = get_bool_option "coq:reversible" in
13161318
let no_tc = get_bool_option "coq:no_tc" in
1319+
let no_coercion = get_bool_option "coq:no_coercion" in
13171320
let keepunivs = get_bool_option "coq:keepunivs" in
13181321
let redflags = get_redflags_option () in
13191322
let algunivs = get_bool_option "coq:keepalgunivs" in
13201323
make_options ~hoas_holes ~local ~warn ~depr ~primitive ~failsafe ~ppwidth
13211324
~pp ~pplevel ~using ~inline ~uinstance ~universe_decl ~reversible ~keepunivs
1322-
~redflags ~no_tc ~algunivs
1325+
~redflags ~no_tc ~no_coercion ~algunivs
13231326
let mk_coq_context ~options state =
13241327
let env = get_global_env state in
13251328
let section = section_ids env in

src/rocq_elpi_HOAS.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type options = {
4848
keepunivs : bool option;
4949
redflags : RedFlags.reds option;
5050
no_tc: bool option;
51+
no_coercion: bool option;
5152
algunivs : bool option;
5253
}
5354

src/rocq_elpi_builtins.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3608,7 +3608,9 @@ Supported attributes:
36083608
- @keepunivs! (default false, do not disregard universe levels)
36093609
- @no-tc! (default false, do not infer typeclasses) |}))))),
36103610
(fun gt ety _ diag ~depth proof_context _ state ->
3611-
let flags = if proof_context.options.no_tc = Some true then {(Pretyping.default_inference_flags false) with use_typeclasses = NoUseTC} else Pretyping.default_inference_flags false in
3611+
let flags = Pretyping.default_inference_flags false in
3612+
let flags = if proof_context.options.no_tc = Some true then {flags with use_typeclasses = NoUseTC} else flags in
3613+
let flags = if proof_context.options.no_coercion = Some true then {flags with use_coercions = false} else flags in
36123614
try
36133615
let sigma = get_sigma state in
36143616
let ety_given, expected_type =
@@ -3655,7 +3657,9 @@ Supported attributes:
36553657
(fun gt es _ diag ~depth proof_context _ state ->
36563658
try
36573659
let sigma = get_sigma state in
3658-
let flags = if proof_context.options.no_tc = Some true then {(Pretyping.default_inference_flags false) with use_typeclasses = NoUseTC} else Pretyping.default_inference_flags false in
3660+
let flags = Pretyping.default_inference_flags false in
3661+
let flags = if proof_context.options.no_tc = Some true then {flags with use_typeclasses = NoUseTC} else flags in
3662+
let flags = if proof_context.options.no_coercion = Some true then {flags with use_coercions = false} else flags in
36593663
let expected_type = Pretyping.IsType in
36603664
let sigma = Evd.push_future_goals sigma in
36613665
let sigma, uj_val, uj_type =

0 commit comments

Comments
 (0)