
History digging points to a commit from 2013: https://github.com/haskell/aeson/commit/260a7e839bfda660bb7e0b715567b35d76cc... I'm too lazy to dig further, but I'd expect that the answer "that instance have always been that way". Back then there weren't machinery to parse keys of maps (we had e.g. `FromJSON (Map Text a)`). Now we have. I'm open to change (and have other small-ish yet breaking changes in mind for aeson), please open an issue, so we can discuss it there. Cheers, Oleg On 3.3.2021 17.27, Olaf Klinke wrote:
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.
Thanks Olaf
[1] https://hackage.haskell.org/package/aeson-1.5.6.0/docs/src/Data.Aeson.Types....
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.