【发布时间】:2021-04-29 15:01:27
【问题描述】:
以下代码触发错误:
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
如何创建像 Value 这样的总和类型,其中一个构造函数采用 HashMap Text Text?
【问题讨论】:
标签: haskell hashmap algebraic-data-types sum-type