为什么 Idris 中的依赖类型不能处理这种情况?
Why can't dependent types in Idris handle this situation?
我想做以下事情:
data Foo : (a : Type) -> (b : Type) -> (c : a -> b -> Type) -> Type where
Bar : a -> (c a) -> Foo a b c
但出现以下错误:
When checking type of test.Bar:
When checking argument c to test.Foo:
Type mismatch between
Type -> Type (Type of c)
and
a -> b -> Type (Expected type)
Specifically:
Type mismatch between
Type
and
b -> Type
这似乎对我有效。也就是说 c
在表达式 Foo a b c
中的类型是正确的,但 Idris 认为它的类型是 b -> Type
,或者我认为是 (c a)
.
我是不是遗漏了什么,或者这是 Idris 的限制?
(c a)
的类型为 b -> Type
,而数据构造函数的所有字段的类型必须为 Type
。正如伊德里斯所说,这是一个错误。您的 c
类型构造函数有两个参数,但您只将它应用于单个 a
.
我想做以下事情:
data Foo : (a : Type) -> (b : Type) -> (c : a -> b -> Type) -> Type where
Bar : a -> (c a) -> Foo a b c
但出现以下错误:
When checking type of test.Bar:
When checking argument c to test.Foo:
Type mismatch between
Type -> Type (Type of c)
and
a -> b -> Type (Expected type)
Specifically:
Type mismatch between
Type
and
b -> Type
这似乎对我有效。也就是说 c
在表达式 Foo a b c
中的类型是正确的,但 Idris 认为它的类型是 b -> Type
,或者我认为是 (c a)
.
我是不是遗漏了什么,或者这是 Idris 的限制?
(c a)
的类型为 b -> Type
,而数据构造函数的所有字段的类型必须为 Type
。正如伊德里斯所说,这是一个错误。您的 c
类型构造函数有两个参数,但您只将它应用于单个 a
.