[英]GHC - constraint in type signature invalid
我正在尝试加载以下定义
data NestedList a = Elem a | List [NestedList a]
flatten :: (NestedList a) => a -> [a]
flatten (Elem x) = [x]
但是GHC给出了一个错误
Expected a constraint, but 'NestedList a' has kind '*'
In the type signature for 'flatten'
类型签名中是否缺少或无效的东西?
提前致谢
=>
之前的部分是一个约束,必须包含类型类,而NestedList
只是一个类型。 你想写的是
flatten :: NestedList a -> [a]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.