废话 "Not in scope" 错误
Nonsense "Not in scope" errors
有时 Agda 会给我一些毫无意义的 "Not in scope" 错误,让我不知所措。这是一个例子:
open import Data.Product
open import Data.Bool
open import Data.Unit
postulate
μ : (Set → Set) → Set
In : {F : Set → Set} → F (μ F) → μ F
unIn : {F : Set → Set} → μ F → F (μ F)
NatT : Set
NatT = μ λ x -> Σ Bool (λ { true -> ⊤; false -> x })
x : NatT
x = In (false , In (true, tt))
这个抱怨 true
不在范围内。考虑到 x = In (true, tt)
工作正常,这甚至更奇怪。为什么会这样?
Not in scope:
true, at /Users/v/agda/mu.agda:14,21-26
(did you mean
'Bool.true' or
'Data.Bool.Bool.true' or
'Data.Bool.true' or
'true'?)
when scope checking true,
少了一个白色space。正确:
x = In (false , In (true , tt))
Agda 说 true,
不在范围内;注意 ,
。 Agda 将大多数 space-free 字符序列视为单个标记,这很奇怪,但通常很有用。
有时 Agda 会给我一些毫无意义的 "Not in scope" 错误,让我不知所措。这是一个例子:
open import Data.Product
open import Data.Bool
open import Data.Unit
postulate
μ : (Set → Set) → Set
In : {F : Set → Set} → F (μ F) → μ F
unIn : {F : Set → Set} → μ F → F (μ F)
NatT : Set
NatT = μ λ x -> Σ Bool (λ { true -> ⊤; false -> x })
x : NatT
x = In (false , In (true, tt))
这个抱怨 true
不在范围内。考虑到 x = In (true, tt)
工作正常,这甚至更奇怪。为什么会这样?
Not in scope:
true, at /Users/v/agda/mu.agda:14,21-26
(did you mean
'Bool.true' or
'Data.Bool.Bool.true' or
'Data.Bool.true' or
'true'?)
when scope checking true,
少了一个白色space。正确:
x = In (false , In (true , tt))
Agda 说 true,
不在范围内;注意 ,
。 Agda 将大多数 space-free 字符序列视为单个标记,这很奇怪,但通常很有用。