Skip to content

Commit d810143

Browse files
committed
Add & T syntax for anonymous binders (_ : T)
1 parent c6586c1 commit d810143

File tree

10 files changed

+26
-15
lines changed

10 files changed

+26
-15
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
overlay analysis https://github.com/proux01/analysis rocq21611 21611
2+
overlay deriving https://github.com/proux01/deriving rocq21611 21611
3+
overlay fcsl_pcm https://github.com/proux01/fcsl-pcm rocq21611 21611
4+
overlay finmap https://github.com/proux01/finmap rocq21611 21611
5+
overlay mathcomp https://github.com/proux01/math-comp rocq21611 21611
6+
overlay mtac2 https://github.com/proux01/Mtac2 rocq21611 21611
7+
overlay oddorder https://github.com/proux01/odd-order rocq21611 21611

doc/changelog/02-specification-language/21611-of-ampersand.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
- **Added:**
2-
new syntactic sugars `of T & ... & T` for anonymous binders
3-
`(_ : T)` in constructors, enabling the
2+
new syntactic sugars `& T` for anonymous binders `(_ : T)`
3+
and `of T & ... & T` for anonymous binders in constructors, enabling the
44
`Variant t := C1 of a & b & c | C2 x y of P x & Q y.` syntax.
55
This adds the new reserved keyword `of`
66
(`#21478 <https://github.com/rocq-prover/rocq/pull/21478>`_,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- **Removed:**
2+
the `of T` syntax for anonymous binders outside of constructors,
3+
use `& T` instead
4+
(`#21611 <https://github.com/rocq-prover/rocq/pull/21611>`_,
5+
by Pierre Roux).

doc/sphinx/language/core/assumptions.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Binders
2020
| @generalizing_binder
2121
| ( @name : @type %| @term )
2222
| ' @pattern0
23+
| & @term99
2324
2425
Various constructions such as :g:`fun`, :g:`forall`, :g:`fix` and :g:`cofix`
2526
*bind* variables. A binding is represented by an identifier. If the binding
@@ -38,6 +39,8 @@ variable can be introduced at the same time. It is also possible to give
3839
the type of the variable as follows:
3940
:n:`(@ident : @type := @term)`.
4041

42+
:n:`& @term99` is syntactic sugar for the anonymous binder :n:`(_ : @term99)`.
43+
4144
`(x : T | P)` is syntactic sugar for `(x : @Stdlib.Init.Specif.sig _ (fun x : T => P))`,
4245
which would more typically be written `(x : {x : T | P})`.
4346
Since `(x : T | P)` uses `sig` directly,

doc/tools/docgram/fullGrammar

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ closed_binder: [
348348
| "`{" LIST1 typeclass_constraint SEP "," "}"
349349
| "`[" LIST1 typeclass_constraint SEP "," "]"
350350
| "'" pattern0
351+
| "&" term99
351352
]
352353

353354
one_open_binder: [

doc/tools/docgram/orderedGrammar

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ binder: [
405405
| generalizing_binder
406406
| "(" name ":" type "|" term ")"
407407
| "'" pattern0
408+
| "&" term99
408409
]
409410

410411
implicit_binders: [

parsing/g_constr.mlg

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,9 @@ GRAMMAR EXTEND Gram
508508
{ List.map (fun (n, b, t) -> CLocalAssum ([n], None, Generalized (MaxImplicit, b), t)) tc }
509509
| "`["; tc = LIST1 typeclass_constraint SEP "," ; "]" ->
510510
{ List.map (fun (n, b, t) -> CLocalAssum ([n], None, Generalized (NonMaxImplicit, b), t)) tc }
511-
| "'"; p = pattern LEVEL "0" -> { [CLocalPattern p] } ] ]
511+
| "'"; p = pattern LEVEL "0" -> { [CLocalPattern p] }
512+
| "&"; c = term LEVEL "99" ->
513+
{ [CLocalAssum ([CAst.make ~loc Anonymous], None, Default Explicit, c)] } ] ]
512514
;
513515
one_open_binder:
514516
[ [ na = name -> { (pat_of_name na, Explicit) }

plugins/ssr/ssrvernac.mlg

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,6 @@ GRAMMAR EXTEND Gram
116116
] ];
117117
END
118118

119-
GRAMMAR EXTEND Gram
120-
GLOBAL: closed_binder;
121-
closed_binder: TOP [
122-
[ ["of" -> { () } | "&" -> { () } ]; c = term LEVEL "99" ->
123-
{ [CLocalAssum ([CAst.make ~loc Anonymous], None, Default Explicit, c)] }
124-
] ];
125-
END
126-
127119
(** Vernacular commands: Prenex Implicits *)
128120

129121
(* This should really be implemented as an extension to the implicit *)

test-suite/prerequisite/ssr_mini_mathcomp.v

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ Structure type := Pack {sort; _ : class_of sort; _ : Type}.
695695
Local Coercion sort : type >-> Sortclass.
696696
Variables (T : Type) (cT : type).
697697
Definition class := let: Pack _ c _ as cT' := cT return class_of cT' in c.
698-
Definition clone c of phant_id class c := @Pack T c T.
698+
Definition clone c & phant_id class c := @Pack T c T.
699699
Let xT := let: Pack T _ _ := cT in T.
700700
Notation xclass := (class : class_of xT).
701701

@@ -798,7 +798,7 @@ Structure type : Type := Pack {sort : Type; _ : class_of sort; _ : Type}.
798798
Local Coercion sort : type >-> Sortclass.
799799
Variables (T : Type) (cT : type).
800800
Definition class := let: Pack _ c _ as cT' := cT return class_of cT' in c.
801-
Definition clone c of phant_id class c := @Pack T c T.
801+
Definition clone c & phant_id class c := @Pack T c T.
802802
Let xT := let: Pack T _ _ := cT in T.
803803
Notation xclass := (class : class_of xT).
804804

@@ -948,7 +948,7 @@ Structure type : Type := Pack {sort; _ : class_of sort; _ : Type}.
948948
Local Coercion sort : type >-> Sortclass.
949949
Variables (T : Type) (cT : type).
950950
Definition class := let: Pack _ c _ as cT' := cT return class_of cT' in c.
951-
Definition clone c of phant_id class c := @Pack T c T.
951+
Definition clone c & phant_id class c := @Pack T c T.
952952
Let xT := let: Pack T _ _ := cT in T.
953953
Notation xclass := (class : class_of xT).
954954

theories/Corelib/ssr/ssreflect.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ Variant put vT sT (v1 v2 : vT) (s : sT) : Prop := Put.
231231

232232
Definition get vT sT v s (p : @put vT sT v v s) := let: Put _ _ _ := p in s.
233233

234-
Definition get_by vT sT of sT -> vT := @get vT sT.
234+
Definition get_by vT sT & sT -> vT := @get vT sT.
235235

236236
End TheCanonical.
237237

0 commit comments

Comments
 (0)