Skip to Content.
Sympa Menu

coq-club - [Coq-Club] Problem with scopes

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

[Coq-Club] Problem with scopes


Chronological Thread 
  • From: Beta Ziliani <beta AT mpi-sws.org>
  • To: Coq Club <coq-club AT inria.fr>
  • Subject: [Coq-Club] Problem with scopes
  • Date: Tue, 23 Aug 2016 11:15:57 -0300
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=beta AT mpi-sws.org; spf=Pass smtp.mailfrom=beta AT mpi-sws.org; spf=None smtp.helo=postmaster AT hera.mpi-klsb.mpg.de
  • Ironport-phdr: 9a23:FWlLmRHL38QsHxMW17Wfgp1GYnF86YWxBRYc798ds5kLTJ75r8+wAkXT6L1XgUPTWs2DsrQf2rOQ6PyrBjBIoc7Y9itTKNoUD15NoP5VtjRoONSCB0z/IayiRA0BN+MGamVY+WqmO1NeAsf0ag6aiHSz6TkPBke3blItdazLE4Lfx/66y/q1s8WKJV4Z3XzmPfgtcF329VyX7ZhOx9M6a+4Y8VjgmjNwYeNYxGdldxq4vi3XwYOOxqNl6DlaoPk79sRNAu3QdqU8SqFEXnx9azhmrOWijxTITBOO630ASS1W10MQW0mWpC39C7z2q2PRsvd3kH2ROtSzRrQpUxyj6b1qQVnmknFUGSQ+9TT9h9B5xJBapBOooR03l4TZfIi9MeJ/O7jCZpUdX2UXDZUZbDBIHo7pN9hHNOEGJ+sN6tCl/1Y=

Hi list,

We've been fighting this issue for way too long, and now it's time to ask the crowd. We like to override the notation for lists only when the list is the argument of certain definition. However, the notation is being pervasive to every list. Aren’t scopes intended for that? What is wrong with our understanding of scopes?

Many thanks,
Beta

Require Import Lists.List.
Import ListNotations.

Delimit Scope pattern_scope with pattern.
Delimit Scope patterns_scope with patterns.

Notation "a => b" := (a, b) (at level 201) : pattern_scope.
Notation "'with' p1 | .. | pn 'end'" :=
  ((cons p1%pattern (.. (cons pn%pattern nil) ..)))
    (at level 91, p1 at level 210, pn at level 210) : patterns_scope.

Definition mymatch (n:nat) (l : list (nat * nat)) := tt.
Arguments mymatch _ _%patterns.
Notation "'mmatch' n ls" := (mymatch n ls) (at level 0).

Close Scope patterns_scope.
Close Scope pattern_scope.

Definition amatch := mmatch 0 with 0 => 1 | 1 => 2 end.
Print amatch. (* Good: amatch = mmatch 0 (with 0 => 1| 1 => 2 end) *)

Definition alist := [0;1;2].
Print alist. (* Bad: alist = (with 0| 1| 2 end)%patterns *)



Archive powered by MHonArc 2.6.18.

Top of Page