removing ad hoc Show instances?

Alexander Bernauer bernauer at inf.ethz.ch
Mon Oct 8 21:25:58 BST 2012


On Mon, Oct 08, 2012 at 12:23:41PM -0700, Mark Tullsen wrote:
> - That is, readsPrec should be able to parse the string produced by
> showsPrec, and should deliver the value that showsPrec started with.
>
>  - The result of show is a syntactically correct Haskell expression
>  containing only constants, given the fixity declarations in force at
>  the point where the type is declared.

Just to complete the picture: if user defined Show instances would
produce syntactically correct Haskell expressions and there would also
be corresponding Read instances, would that be also okay?

For example, Data.Ident contains an "hash to speed up equality check" of
type Int. The value can be calculated from the identifier itself. So one
could have a Show instance omitting the hash and a Read instance
re-calculating it.

>  So, it would seem to make sense to follow the spirit of the built-in
>  instances.

In general I agree with this, although this seems not to be common sense
in the Haskell community. For example, Text.PrettyPrint.Doc has a
user-defined show instance calling the fullRender function.

> That's exactly right, I'd like to see all of them removed.

Hmm, that's quite a change.

We will have to carefully check for which purpuses those instances are
used currently. Some instances such as those in Data.Error and
Parser.Tokens seem to be specifically crafted.

I could find and adapt all points of usage in the library itself, but how
should we handle existing client code? Break it and release Language.C
0.5?

Could you maybe motivate, why all these user-defined Show instances are
such an annoyance to you that you even consider forking Language.C to
get rid of them?

> (But maybe we need another class 'ConciseShow'---or the like---so as
> not to throw away the code that previously showed these values.)

I am pretty sure that one or the other implementation of show is
actually needed, so ConciseShow or MyShow etc. will in fact be required.
 
> P.S., It looks I *did* cc the list. :-)

Sorry, my bad :/
 
Greetings

Alex
-------------- 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/20121008/2cbe98ab/attachment.pgp>


More information about the Language-c mailing list