为什么列表中的等式中的“中立”不归一化为“ []”?

时间:2018-10-12 08:22:34

标签: typeclass idris type-level-computation

以下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

1 个答案:

答案 0 :(得分:1)

neutral将被解释为隐式参数,因为它是小写字母并出现在类型声明中。但是您可以只指定模块。 :doc neutral给了我Prelude.Algebra.neutral

foo : (xs : List Nat) -> xs = (Algebra.neutral <+> xs)
foo xs = Refl