[core libraries] Future of "Text.Show.Functions" module

Henning Thielemann lemming at henning-thielemann.de
Sun Oct 19 13:19:42 UTC 2014


On Sun, 19 Oct 2014, Michael Snoyman wrote:

> Overall, the problem is that we've overloaded Show in (at least) three different ways:
> 
> * Textual serialization
> * Debugging
> * User-friendly display of data

Unfortunately, the Show class is not used consistently, with the different 
uses you have listed.

The automatically derived Show instances show valid Haskell expressions, 
that you can enter into GHCi in order to get back the shown value. I think 
we should stick to that meaning.

Strictly conforming to this rule would also mean that using 'show' for 
formatting numbers is not precisely correct, because we cannot expect that 
other tools can parse all ways of writing number literals in Haskell. 
Maybe printf is better here, but it is unfortunately not total.

Following the above rule for functions would mean, that 'show' should emit 
an expression that represents the function, e.g. something like

Prelude> show ((\x->x*x) :: Int -> Int)
fromJust . flip lookup [(0,0), (1,1), (-1,1), (2,4), (-2,4), ...


More information about the Libraries mailing list