Map package:dhall

Map type used to represent records and unions
A Map that remembers the original ordering of keys This is primarily used so that formatting preserves field order This is done primarily to avoid a dependency on insert-ordered-containers and also to improve performance
Decode a Map from a toMap expression or generally a Prelude.Map.Type.
>>> input (Dhall.map strictText bool) "toMap { a = True, b = False }"
fromList [("a",True),("b",False)]

>>> input (Dhall.map strictText bool) "[ { mapKey = \"foo\", mapValue = True } ]"
fromList [("foo",True)]
If there are duplicate mapKeys, later mapValues take precedence:
>>> let expr = "[ { mapKey = 1, mapValue = True }, { mapKey = 1, mapValue = False } ]"

>>> input (Dhall.map natural bool) expr
fromList [(1,False)]
Transform all values in a Map using the supplied function, deleting the key if the function returns Nothing
>>> mapMaybe Data.Maybe.listToMaybe (fromList [("C",[1]),("B",[]),("A",[3])])
fromList [("C",1),("A",3)]
Transform the values of a Map using their corresponding key
mapWithKey (pure id) = id

mapWithKey (liftA2 (.) f g) = mapWithKey f . mapWithKey g
mapWithKey f mempty = mempty

mapWithKey f (x <> y) = mapWithKey f x <> mapWithKey f y
>>> mapWithKey (,) (fromList [("B",1),("A",2)])
fromList [("B",("B",1)),("A",("A",2))]
Identical to Control.Lens.mapMOf
ToMap x (Just t)                         ~  toMap x : t
ToMap x  Nothing                         ~  toMap x
This replaces a record of key-value pairs with the equivalent use of toMap This is currently not used by dhall lint because this would sort Map keys, which is not necessarily a behavior-preserving change, but is still made available as a convenient rewrite rule. For example, {json,yaml}-to-dhall use this rewrite to simplify their output.
Fold all of the key-value pairs in a Map, in their original order
>>> foldMapWithKey (,) (fromList [("B",[1]),("A",[2])])
("BA",[1,2])
Create a Map from a Data.Map.Map
Convert a Dhall.Map.Map to a Data.Map.Map
>>> toMap (fromList [("B",1),("A",2)]) -- Order is lost upon conversion
fromList [("A",2),("B",1)]
Decode a HashMap from a toMap expression or generally a Prelude.Map.Type.
>>> fmap (List.sort . HashMap.toList) (input (Dhall.hashMap strictText bool) "toMap { a = True, b = False }")
[("a",True),("b",False)]

>>> fmap (List.sort . HashMap.toList) (input (Dhall.hashMap strictText bool) "[ { mapKey = \"foo\", mapValue = True } ]")
[("foo",True)]
If there are duplicate mapKeys, later mapValues take precedence:
>>> let expr = "[ { mapKey = 1, mapValue = True }, { mapKey = 1, mapValue = False } ]"

>>> input (Dhall.hashMap natural bool) expr
fromList [(1,False)]
Decode a tuple from a Prelude.Map.Entry record.
>>> input (pairFromMapEntry strictText natural) "{ mapKey = \"foo\", mapValue = 3 }"
("foo",3)
merge x y, Some x or toMap x, unparenthesized.
Parse the toMap keyword This corresponds to the toMap rule from the official grammar