diff options
| author | herbelin | 2012-01-20 21:08:33 +0000 |
|---|---|---|
| committer | herbelin | 2012-01-20 21:08:33 +0000 |
| commit | 22a8453f551349bbafa14b914aa784693dcf3615 (patch) | |
| tree | 3c6a38d4a785120a6094c9850df1bb9165c26b7d | |
| parent | 033d8f9628c54218378ee539648b6df6bfcbdb1e (diff) | |
Notations with binders: Accepting using notations for functional terms
which do not necessarily depend on their parameter (e.g. a notation
for "fun x => t" might match also "fun _ => t").
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@14926 85f007b7-540e-0410-9357-904b9bb8a0f7
| -rw-r--r-- | interp/topconstr.ml | 7 | ||||
| -rw-r--r-- | test-suite/output/Notations2.out | 4 | ||||
| -rw-r--r-- | test-suite/output/Notations2.v | 10 |
3 files changed, 19 insertions, 2 deletions
diff --git a/interp/topconstr.ml b/interp/topconstr.ml index 0db70e59c1..32f20e0a84 100644 --- a/interp/topconstr.ml +++ b/interp/topconstr.ml @@ -564,8 +564,11 @@ let match_opt f sigma t1 t2 = match (t1,t2) with | _ -> raise No_match let match_names metas (alp,sigma) na1 na2 = match (na1,na2) with - | (Name id1,Name id2) when List.mem id2 (fst metas) -> - alp, bind_env alp sigma id2 (GVar (dummy_loc,id1)) + | (_,Name id2) when List.mem id2 (fst metas) -> + let rhs = match na1 with + | Name id1 -> GVar (dummy_loc,id1) + | Anonymous -> GHole (dummy_loc,Evd.InternalHole) in + alp, bind_env alp sigma id2 rhs | (Name id1,Name id2) -> (id1,id2)::alp,sigma | (Anonymous,Anonymous) -> alp,sigma | _ -> raise No_match diff --git a/test-suite/output/Notations2.out b/test-suite/output/Notations2.out index 47741e439a..3b3351d330 100644 --- a/test-suite/output/Notations2.out +++ b/test-suite/output/Notations2.out @@ -46,3 +46,7 @@ match n with | plus2 _ :: _ => 2 end : list(nat) -> nat +# x : nat => x + : nat -> nat +# _ : nat => 2 + : nat -> nat diff --git a/test-suite/output/Notations2.v b/test-suite/output/Notations2.v index e902a3c273..1fcbe858a8 100644 --- a/test-suite/output/Notations2.v +++ b/test-suite/output/Notations2.v @@ -83,3 +83,13 @@ Notation "'mylet' f [ x ; .. ; y ] := t 'in' u":= Check mylet f [x;y;z;(a:bool)] := x+y+z+1 in f 0 1 2. *) + +(* Check notations for functional terms which do not necessarily + depend on their parameter *) +(* Old request mentioned again on coq-club 20/1/2012 *) + +Notation "# x : T => t" := (fun x : T => t) + (at level 0, t at level 200, x ident). + +Check # x : nat => x. +Check # _ : nat => 2. |
