以下Idris定义对Idris 1.3.0进行类型检查:
foo : (xs : List Nat) -> xs = ([] <+> xs)
foo xs = Refl
但是,这不是:
foo : (xs : List Nat) -> xs = (neutral <+> xs)
foo xs = Refl
出现以下类型错误:
When checking right hand side of foo with expected type
xs = neutral <+> xs
Type mismatch between
neutral ++ xs = neutral ++ xs (Type of Refl)
and
xs = neutral ++ xs (Expected type)
Specifically:
Type mismatch between
neutral ++ xs
and
xs
为什么neutral <+> xs
在这里不规范为xs
?
答案 0 :(得分:1)
neutral
将被解释为隐式参数,因为它是小写字母并出现在类型声明中。但是您可以只指定模块。 :doc neutral
给了我Prelude.Algebra.neutral
:
foo : (xs : List Nat) -> xs = (Algebra.neutral <+> xs)
foo xs = Refl