问题描述
以下代码触发错误:
B
编译器抱怨:
B
如何创建像 import Data.HashMap.Strict (HashMap) -- from unordered-containers
import Data.Text
data Value =
VText Text
| VList [Text]
| VMap HashMap Text Text
deriving Show
这样的和类型,其中一个构造函数采用 Expecting two more arguments to ‘HashMap’
Expected a type,but ‘HashMap’ has kind ‘* -> * -> *’
In the type ‘HashMap’
In the definition of data constructor ‘VMap’
In the data declaration for ‘Value’typecheck
?
解决方法
通过使用括号来消除 HashMap
中 VMap
的参数歧义:
data Value =
VText Text
| VList [Text]
| VMap (HashMap Text Text)
deriving Show