Reputation: 1422
I'm trying to load the following definition
data NestedList a = Elem a | List [NestedList a]
flatten :: (NestedList a) => a -> [a]
flatten (Elem x) = [x]
But GHC is giving an error
Expected a constraint, but 'NestedList a' has kind '*'
In the type signature for 'flatten'
Is there something missing or invalid in the type signature?
Thanks in advance
Upvotes: 0
Views: 33
Reputation: 9726
The part before =>
is a constraint and must contain type classes, while NestedList
is just a type. What you wanted to write is
flatten :: NestedList a -> [a]
Upvotes: 1