[Haskell-cafe] aeson: instance FromJSON IntMap

Olaf Klinke olf at aatal-apotheke.de
Wed Mar 3 15:27:46 UTC 2021

Dear Cafe, 

why is Aeson's instance FromJSON IntMap so different from the instance
of Map? Apparently the Map instance expects an Object (the dictionary)
while the IntMap instance [1] is implemented using IntMap.fromList, so
it expects an array. 
I can of course decode the JSON as (Map Int) and then use 
IntMap.fromAscList . Map.assocs
but how efficient is that? And it also relies on Map.assocs producing
the list in the order expected by fromAscList which (unlikely) could be
broken in a future version of containers. 



More information about the Haskell-Cafe mailing list