Dhall 中的AMap只是/对中的一个:ListmapKeymapValue
$ 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