Dhall 中的AMap
只是/对中的一个:List
mapKey
mapValue
$ dhall <<< 'https://prelude.dhall-lang.org/v16.0.0/Map/Type'
λ(k : Type) → λ(v : Type) → List { mapKey : k, mapValue : v }
...并且 Haskell 实现将 2 元组编码为(a, b)
as { _1 : a, _2 : b }
,因此与您的 Haskell 类型对应的 Dhall 类型为:
List { mapKey : { _1 : List Text, _2 : List Text }, mapValue : Text }
您是正确的,您不能使用它toMap
来构建该类型的值,因为toMap
仅支持Map
带有Text
-valued 键的 s 。但是,由于 aMap
只是特定类型的同义词,List
您可以直接写出List
(就像在 Haskell 中使用Data.Map.fromList
时一样),如下所示:
let example
: List { mapKey : { _1 : List Text, _2 : List Text }, mapValue : Text }
= [ { mapKey = { _1 = [ "a", "b" ], _2 = [ "c", "d" ] }, mapValue = "e" }
, { mapKey = { _1 = [ "f" ], _2 = [ "g", "h", "i" ] }, mapValue = "j" }
]
in example