Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ltac2val:() quotation in ltac1 to return Ltac1.t values
- Loading branch information
1 parent
08920fc
commit 9dbf1b7
Showing
8 changed files
with
156 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
overlay serapi https://github.com/SkySkimmer/coq-serapi ltac2in1 17575 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- **Added:** | ||
Ltac2 quotations :ref:`ltac2val:(ltac2 tactic) <ltac2in1>` in Ltac1 which produce Ltac1 values | ||
(as opposed to `ltac2:()` quotations which are only useful for their side effects) | ||
(`#17575 <https://github.com/coq/coq/pull/17575>`_, | ||
by Gaëtan Gilbert). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
Require Import Ltac2.Ltac2. | ||
|
||
Import Constr.Unsafe. | ||
|
||
(* manual Ltac1.lambda wrapping *) | ||
Ltac add1 := | ||
ltac2val:(Ltac1.lambda (fun y => | ||
let y := Option.get (Ltac1.to_constr y) in | ||
let y := make (App constr:(S) [|y|]) in | ||
Ltac1.of_constr y)). | ||
|
||
(* automatic Ltac1.lambda wrapping | ||
also check that it's done in the right order *) | ||
Ltac add1' := | ||
ltac2val:(y z |- | ||
let y := Option.get (Ltac1.to_constr y) in | ||
let y := make (App constr:(S) [|y|]) in | ||
Ltac1.of_constr y). | ||
|
||
Set Default Proof Mode "Classic". | ||
|
||
Goal True. | ||
let z := constr:(0) in | ||
let v := add1 z in | ||
constr_eq v 1. | ||
|
||
let a := constr:(0) in | ||
let v := add1' a 2 in | ||
constr_eq v 1. | ||
|
||
(* currying works *) | ||
let a := constr:(0) in | ||
let v := add1' a in | ||
let v' := v 2 in | ||
constr_eq v' 1. | ||
|
||
(* check order of arguments *) | ||
Fail let a := constr:(0) in | ||
let v := add1' 2 a in | ||
constr_eq v 1. | ||
|
||
(* printer doesn't anomaly *) | ||
let v := add1' in | ||
idtac v. | ||
|
||
Abort. | ||
|
||
(* With ltac2:(x) this would succeed without warning | ||
"this expression should have type unit but has type constr" | ||
because ltac2:(x) only checks that x has type unifiable with unit. | ||
It's not a big problem as the constr gets discarded by ltac2:() | ||
so we just get an incomplete warning (maybe fixed in the future). | ||
With ltac2val such a weak check would produce runtime anomalies. | ||
*) | ||
Fail Ltac2 bad x := | ||
let c1 := constr:(ltac:(ltac2val:(x))) in | ||
let c2 := constr:($x) in | ||
(). |