Better implementation of Show instance for Data.Scientific

Phil Ruffwind rf at
Sat May 2 14:16:57 UTC 2015

I think it's strange to build the display mode into the data type
Scientific, unless Scientific's primary purpose is for *display*
rather than representation.  For one thing, it mixes two separate
roles into one.  For another, it would violate the usual expectations
for Eq: there would be x and y such that

    x == y


    show x /= show y

I prefer the approach of using a separate function (e.g. 'pretty'), as
it gives the user more control in situations where Show's default
format does not satisfy the needs.  If Aeson is not formatting numbers
in the way the user expects, then that's really a problem with Aeson.

OTOH, I think it makes sense to automatically drop the '.0' when the
number is integral, and that could be built into the Show instance.
Of course, there's the question of whether such a change would break
other packages...

More information about the Libraries mailing list