[Haskell-cafe] aeson: instance FromJSON IntMap

Oleg Grenrus oleg.grenrus at iki.fi
Wed Mar 3 16:16:03 UTC 2021

History digging points to a commit from 2013:
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-
> _______________________________________________
> 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.

More information about the Haskell-Cafe mailing list