我想要声明一个新类型的值如下:
data Value m = Wrong | Num Int | Fun (Value -> m Value)
GHCI抱怨道:
<interactive>:160:39:
Expecting one more argument to ‘Value’
Expected a type, but ‘Value’ has kind ‘k0 -> *’
In the type ‘Value -> m Value’
In the definition of data constructor ‘Fun’
In the data declaration for ‘Value’
的代码
答案 0 :(得分:4)
由于Value
采用了类型参数,因此您需要在使用Value
时随时提供该参数。也就是说,您应该将其称为Value m
,而不仅仅是Value
。所以你的类型定义应该是:
data Value m = Wrong | Num Int | Fun ((Value m) -> m (Value m))