Reputation: 3
I’m tring to declare a new type Value as below:
data Value m = Wrong | Num Int | Fun (Value -> m Value)
And GHCI complains:
<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: I'm trying to implement code of The essence of functional programming
Upvotes: 0
Views: 165
Reputation: 370455
Since Value
takes a type parameter, you need to supply that parameter any time you use Value
. That is, you should refer to it as Value m
, not just Value
. So your type definition should be:
data Value m = Wrong | Num Int | Fun ((Value m) -> m (Value m))
Upvotes: 4