>>> 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)]
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))]
ToMap x (Just t) ~ toMap x : t ToMap x Nothing ~ toMap x
>>> foldMapWithKey (,) (fromList [("B",[1]),("A",[2])]) ("BA",[1,2])
>>> 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)]
>>> input (pairFromMapEntry strictText natural) "{ mapKey = \"foo\", mapValue = 3 }" ("foo",3)