-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ltac2 Util: Add various destKind helpers
- Loading branch information
1 parent
08eb6f3
commit 40cb50f
Showing
18 changed files
with
204 additions
and
0 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
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,11 @@ | ||
Require Import Ltac2.Ltac2. | ||
Require Export Rewriter.Util.FixCoqMistakes. | ||
Import Ltac2.Constr.Unsafe. | ||
|
||
Ltac2 Type exn ::= [ Not_an_app (kind) ]. | ||
Ltac2 destApp (c : constr) := | ||
let k := kind c in | ||
match k with | ||
| App f args => (f, args) | ||
| _ => Control.throw (Not_an_app k) | ||
end. |
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,11 @@ | ||
Require Import Ltac2.Ltac2. | ||
Require Export Rewriter.Util.FixCoqMistakes. | ||
Import Ltac2.Constr.Unsafe. | ||
|
||
Ltac2 Type exn ::= [ Not_a_case (kind) ]. | ||
Ltac2 destCase (c : constr) := | ||
let k := kind c in | ||
match k with | ||
| Case a b c d e => (a, b, c, d, e) | ||
| _ => Control.throw (Not_a_case k) | ||
end. |
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,11 @@ | ||
Require Import Ltac2.Ltac2. | ||
Require Export Rewriter.Util.FixCoqMistakes. | ||
Import Ltac2.Constr.Unsafe. | ||
|
||
Ltac2 Type exn ::= [ Not_a_cast (kind) ]. | ||
Ltac2 destCast (c : constr) := | ||
let k := kind c in | ||
match k with | ||
| Cast x y z => (x, y, z) | ||
| _ => Control.throw (Not_a_cast k) | ||
end. |
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,11 @@ | ||
Require Import Ltac2.Ltac2. | ||
Require Export Rewriter.Util.FixCoqMistakes. | ||
Import Ltac2.Constr.Unsafe. | ||
|
||
Ltac2 Type exn ::= [ Not_a_cofix (kind) ]. | ||
Ltac2 destCoFix (c : constr) := | ||
let k := kind c in | ||
match k with | ||
| CoFix x y z => (x, y, z) | ||
| _ => Control.throw (Not_a_cofix k) | ||
end. |
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,11 @@ | ||
Require Import Ltac2.Ltac2. | ||
Require Export Rewriter.Util.FixCoqMistakes. | ||
Import Ltac2.Constr.Unsafe. | ||
|
||
Ltac2 Type exn ::= [ Not_a_constant (kind) ]. | ||
Ltac2 destConstant (c : constr) := | ||
let k := kind c in | ||
match k with | ||
| Constant e inst => (e, inst) | ||
| _ => Control.throw (Not_a_constant k) | ||
end. |
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,11 @@ | ||
Require Import Ltac2.Ltac2. | ||
Require Export Rewriter.Util.FixCoqMistakes. | ||
Import Ltac2.Constr.Unsafe. | ||
|
||
Ltac2 Type exn ::= [ Not_a_constructor (kind) ]. | ||
Ltac2 destConstructor (c : constr) := | ||
let k := kind c in | ||
match k with | ||
| Constructor e inst => (e, inst) | ||
| _ => Control.throw (Not_a_constructor k) | ||
end. |
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,11 @@ | ||
Require Import Ltac2.Ltac2. | ||
Require Export Rewriter.Util.FixCoqMistakes. | ||
Import Ltac2.Constr.Unsafe. | ||
|
||
Ltac2 Type exn ::= [ Not_an_evar (kind) ]. | ||
Ltac2 destEvar (c : constr) := | ||
let k := kind c in | ||
match k with | ||
| Evar e inst => (e, inst) | ||
| _ => Control.throw (Not_an_evar k) | ||
end. |
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,11 @@ | ||
Require Import Ltac2.Ltac2. | ||
Require Export Rewriter.Util.FixCoqMistakes. | ||
Import Ltac2.Constr.Unsafe. | ||
|
||
Ltac2 Type exn ::= [ Not_a_fix (kind) ]. | ||
Ltac2 destFix (c : constr) := | ||
let k := kind c in | ||
match k with | ||
| Fix x y z w => (x, y, z, w) | ||
| _ => Control.throw (Not_a_fix k) | ||
end. |
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,11 @@ | ||
Require Import Ltac2.Ltac2. | ||
Require Export Rewriter.Util.FixCoqMistakes. | ||
Import Ltac2.Constr.Unsafe. | ||
|
||
Ltac2 Type exn ::= [ Not_an_ind (kind) ]. | ||
Ltac2 destInd (c : constr) := | ||
let k := kind c in | ||
match k with | ||
| Ind e inst => (e, inst) | ||
| _ => Control.throw (Not_an_ind k) | ||
end. |
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,11 @@ | ||
Require Import Ltac2.Ltac2. | ||
Require Export Rewriter.Util.FixCoqMistakes. | ||
Import Ltac2.Constr.Unsafe. | ||
|
||
Ltac2 Type exn ::= [ Not_a_lambda (kind) ]. | ||
Ltac2 destLambda (c : constr) := | ||
let k := kind c in | ||
match k with | ||
| Lambda x f => (x, f) | ||
| _ => Control.throw (Not_a_lambda k) | ||
end. |
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,11 @@ | ||
Require Import Ltac2.Ltac2. | ||
Require Export Rewriter.Util.FixCoqMistakes. | ||
Import Ltac2.Constr.Unsafe. | ||
|
||
Ltac2 Type exn ::= [ Not_a_let_in (kind) ]. | ||
Ltac2 destLetIn (c : constr) := | ||
let k := kind c in | ||
match k with | ||
| LetIn x y z => (x, y, z) | ||
| _ => Control.throw (Not_a_let_in k) | ||
end. |
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,11 @@ | ||
Require Import Ltac2.Ltac2. | ||
Require Export Rewriter.Util.FixCoqMistakes. | ||
Import Ltac2.Constr.Unsafe. | ||
|
||
Ltac2 Type exn ::= [ Not_a_meta (kind) ]. | ||
Ltac2 destMeta (c : constr) := | ||
let k := kind c in | ||
match k with | ||
| Meta e => e | ||
| _ => Control.throw (Not_a_meta k) | ||
end. |
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,11 @@ | ||
Require Import Ltac2.Ltac2. | ||
Require Export Rewriter.Util.FixCoqMistakes. | ||
Import Ltac2.Constr.Unsafe. | ||
|
||
Ltac2 Type exn ::= [ Not_a_prod (kind) ]. | ||
Ltac2 destProd (c : constr) := | ||
let k := kind c in | ||
match k with | ||
| Prod x f => (x, f) | ||
| _ => Control.throw (Not_a_prod k) | ||
end. |
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,11 @@ | ||
Require Import Ltac2.Ltac2. | ||
Require Export Rewriter.Util.FixCoqMistakes. | ||
Import Ltac2.Constr.Unsafe. | ||
|
||
Ltac2 Type exn ::= [ Not_a_proj (kind) ]. | ||
Ltac2 destProj (c : constr) := | ||
let k := kind c in | ||
match k with | ||
| Proj p v => (p, v) | ||
| _ => Control.throw (Not_a_proj k) | ||
end. |
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,11 @@ | ||
Require Import Ltac2.Ltac2. | ||
Require Export Rewriter.Util.FixCoqMistakes. | ||
Import Ltac2.Constr.Unsafe. | ||
|
||
Ltac2 Type exn ::= [ Not_a_rel (kind) ]. | ||
Ltac2 destRel (c : constr) := | ||
let k := kind c in | ||
match k with | ||
| Rel i => i | ||
| _ => Control.throw (Not_a_rel k) | ||
end. |
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,11 @@ | ||
Require Import Ltac2.Ltac2. | ||
Require Export Rewriter.Util.FixCoqMistakes. | ||
Import Ltac2.Constr.Unsafe. | ||
|
||
Ltac2 Type exn ::= [ Not_a_sort (kind) ]. | ||
Ltac2 destSort (c : constr) := | ||
let k := kind c in | ||
match k with | ||
| Sort s => s | ||
| _ => Control.throw (Not_a_sort k) | ||
end. |
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,11 @@ | ||
Require Import Ltac2.Ltac2. | ||
Require Export Rewriter.Util.FixCoqMistakes. | ||
Import Ltac2.Constr.Unsafe. | ||
|
||
Ltac2 Type exn ::= [ Not_a_var (kind) ]. | ||
Ltac2 destVar (c : constr) := | ||
let k := kind c in | ||
match k with | ||
| Var v => v | ||
| _ => Control.throw (Not_a_var k) | ||
end. |