Philip Wadler
2018-04-18 18:50:35 UTC
Consider the following simple variant of an example in the user manual.
---
open import Data.List using (List; _â·_; [])
open import Data.Bool using (Bool; true; false)
module Sort(A : Set)(_â€_ : A â A â Bool)(_â_ : A â A â A)(zero : A) where
infix 1 _â€_
infix 2 _â_
insert : A â List A â List A
insert x [] = x â· []
insert x (y â· ys) with zero †(y â x)
insert x (y â· ys) | true = x â· y â· ys
insert x (y â· ys) | false = y â· insert x ys
sort : List A â List A
sort [] = []
sort (x â· xs) = insert x (sort xs)
---
This works fine. But now say I add infix declarations in so I can omit
parentheses.
---
open import Data.List using (List; _â·_; [])
open import Data.Bool using (Bool; true; false)
module Sort(A : Set)(_â€_ : A â A â Bool)(_â_ : A â A â A)(zero : A) where
infix 1 _â€_
infix 2 _â_
insert : A â List A â List A
insert x [] = x â· []
insert x (y â· ys) with zero †(y â x)
insert x (y â· ys) | true = x â· y â· ys
insert x (y â· ys) | false = y â· insert x ys
sort : List A â List A
sort [] = []
sort (x â· xs) = insert x (sort xs)
---
This yields the error message:
/Users/wadler/sf/src/extra/ModuleInfix.agda:8,11-14
message.
1. What is the right way to declare fixity of infix parameters to a module?
2. Where is this documented?
Cheers, -- P
. \ Philip Wadler, Professor of Theoretical Computer Science,
. /\ School of Informatics, University of Edinburgh
. / \ and Senior Research Fellow, IOHK
. http://homepages.inf.ed.ac.uk/wadler/
---
open import Data.List using (List; _â·_; [])
open import Data.Bool using (Bool; true; false)
module Sort(A : Set)(_â€_ : A â A â Bool)(_â_ : A â A â A)(zero : A) where
infix 1 _â€_
infix 2 _â_
insert : A â List A â List A
insert x [] = x â· []
insert x (y â· ys) with zero †(y â x)
insert x (y â· ys) | true = x â· y â· ys
insert x (y â· ys) | false = y â· insert x ys
sort : List A â List A
sort [] = []
sort (x â· xs) = insert x (sort xs)
---
This works fine. But now say I add infix declarations in so I can omit
parentheses.
---
open import Data.List using (List; _â·_; [])
open import Data.Bool using (Bool; true; false)
module Sort(A : Set)(_â€_ : A â A â Bool)(_â_ : A â A â A)(zero : A) where
infix 1 _â€_
infix 2 _â_
insert : A â List A â List A
insert x [] = x â· []
insert x (y â· ys) with zero †(y â x)
insert x (y â· ys) | true = x â· y â· ys
insert x (y â· ys) | false = y â· insert x ys
sort : List A â List A
sort [] = []
sort (x â· xs) = insert x (sort xs)
---
This yields the error message:
/Users/wadler/sf/src/extra/ModuleInfix.agda:8,11-14
The following names are not declared in the same scope as their
syntax or fixity declaration (i.e., either not in scope at all,
imported from another module, or declared in a super module): _â€_
_â_
when scope checking the declaration
module Sort (A : Set)(_â€_ : A â A â Bool)(_â_ : A â A â A)
(zero : A) where
Moving the infix declarations before the module yields a similar errorsyntax or fixity declaration (i.e., either not in scope at all,
imported from another module, or declared in a super module): _â€_
_â_
when scope checking the declaration
module Sort (A : Set)(_â€_ : A â A â Bool)(_â_ : A â A â A)
(zero : A) where
message.
1. What is the right way to declare fixity of infix parameters to a module?
2. Where is this documented?
Cheers, -- P
. \ Philip Wadler, Professor of Theoretical Computer Science,
. /\ School of Informatics, University of Edinburgh
. / \ and Senior Research Fellow, IOHK
. http://homepages.inf.ed.ac.uk/wadler/