我正在尝试声明一个新类型值,如下所示:
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’
PS:我正在尝试实现代码 The essence of functional programming
由于Value
采用类型参数,因此您需要在任何时候使用Value
. 也就是说,您应该将其称为Value m
,而不仅仅是Value
。所以你的类型定义应该是:
data Value m = Wrong | Num Int | Fun ((Value m) -> m (Value m))
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句