The following code triggers an error:
import Data.HashMap.Strict (HashMap) -- from unordered-containers
import Data.Text
data Value =
VText Text
| VList [Text]
| VMap HashMap Text Text
deriving Show
The compiler complains that:
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
How can I create a sum type like Value
where one of the constructors takes a HashMap Text Text
?
By using parenthesis to disambiguate parameters for HashMap
in VMap
:
data Value =
VText Text
| VList [Text]
| VMap (HashMap Text Text)
deriving Show