Skip to content

Commit

Permalink
Merge PR coq#18370: Ltac2: Take some small APIs from rewriter (fst/snd)
Browse files Browse the repository at this point in the history
Reviewed-by: ppedrot
Co-authored-by: ppedrot <[email protected]>
  • Loading branch information
coqbot-app[bot] and ppedrot authored Jan 30, 2024
2 parents a6d226f + be1bbe2 commit 18b537d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doc/changelog/06-Ltac2-language/18370-ltac2-apis.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- **Added:**
`fst` and `snd` in `Ltac2.Init`
(`#18370 <https://github.com/coq/coq/pull/18370>`_,
by Gaëtan Gilbert).
2 changes: 2 additions & 0 deletions test-suite/output/ltac2_printabout.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
fst : 'a * 'b -> 'a
snd : 'b * 'a -> 'a
type : constr -> constr
Ltac2 type : constr -> constr
type := @external "coq-core.plugins.ltac2" "constr_type"
Expand Down
5 changes: 5 additions & 0 deletions user-contrib/Ltac2/Init.v
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ Ltac2 Type ('a, 'b, 'c, 'd) format.
Ltac2 Type exn := [ .. ].
Ltac2 Type 'a array.

(** Tuples *)

Ltac2 fst (p:'a * 'b) : 'a := let (x,_) := p in x.
Ltac2 snd (p:'a * 'b) : 'b := let (_,y) := p in y.

(** Pervasive types *)

Ltac2 Type 'a option := [ None | Some ('a) ].
Expand Down

0 comments on commit 18b537d

Please sign in to comment.