removing ad hoc Show instances?

Alexander Bernauer bernauer at inf.ethz.ch
Wed Sep 26 09:31:03 BST 2012


Hi Mark,

On Tue, Sep 25, 2012 at 05:02:08PM -0700, Mark Tullsen wrote:
>     (I'll forgo an excursus on the significant advantages of this and
>     my diatribe against ad hoc Show instances.)

Sorry if this is obvious, but I am really interested in learning about
these advantages. Also, I have heard different opinions on for which
purposes Show should be used.

We once had a discussion on this list, that the Show instances of all
AST nodes should be canonical, such that they can be parsed by the
Haskell parser (see discussion starting from [1]). Unfortunatelly,
nobody took the time to acutally do this. But I am still
convinced that this is a good idea.

And AFAICS this goes hand in hand with what you are suggesting.
However, the Haskell report does not enforce that automatically derived
Show instances produce parsable strings: "Strings produced by showsPrec
are usually readable by readsPrec [2]". Any wisdom or experience here? I
would just give it a try.

If we agree on what we want I would volunteer to finally provide the
proper patch.

We have ad-hoc Show instances in the following modules:
 - Data.Ident
 - Data.Error
 - Data.Position
 - Data.Node
 - Syntax.Constants (<- concerns [1])
 - Analysis.DefTable
 - Analysis.SemRep
 - Analysis.SemError
 - Parser.Tokens
 - Parser.ParserMonad

To which instances are you referring to?

Greetings

Alex

[1]
http://projects.haskell.org/pipermail/language-c/2011-May/000065.html

[2] http://www.haskell.org/onlinereport/basic.html (6.3.3)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://projects.haskell.org/pipermail/language-c/attachments/20120926/78a49d6b/attachment.pgp>


More information about the Language-c mailing list