为什么不进行以下类型检查:
v1 : mod 3 2 = 1
v1 = Refl
然而,这将很好地进行类型检查:
v2 : 3 - 2 = 1
v2 = Refl
最佳答案
这是由于 mod
的偏袒而发生的功能(感谢 @AntonTrunov 澄清)。它是多态的,默认数字常量是 Integer
s。
Idris> :t mod
mod : Integral ty => ty -> ty -> ty
Idris> :t 3
3 : Integer
Idris> :t mod 3 2
mod 3 2 : Integer
对于
Integer
类型 mod
功能不全。而是使用
modNatNZ
功能,因此所有类型都可以完美检查并正常工作。v1 : modNatNZ 3 2 SIsNotZ = 1
v1 = Refl
关于dependent-type - 为什么不涉及 "mod"的相等性不在 Idris 中进行类型检查?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44672590/