例如,如何定义已存在的数据类型[Vegetables]的小写常量“corn”?
我尝试过使用
type corn = [Vegetables]
但它产生了“格式错误的类型和/或类声明”......
我想收到一些建议。提前谢谢。
答案 0 :(得分:5)
合理地猜测你的意思,以及Vegetables
类型的构造函数......
corn :: [Vegetables]
corn = [Corn]
这与任何其他顶级绑定相同。类型签名甚至不是必需的,只是常用的文档。
答案 1 :(得分:4)