removing ad hoc Show instances?

Mark Tullsen tullsen at galois.com
Mon Oct 8 20:23:41 BST 2012


Hi Alex,


On Oct 7, 2012, at 8:23 AM, Alexander Bernauer wrote:

> Hi Mark,
> 
> On Mon, Oct 01, 2012 at 04:45:54PM -0700, Mark Tullsen wrote:
>> Sorry for the delayed response ...
> 
> dito :)
> 
>> From my point of view, a good design approach is to separate these two concerns:
> 
> Thank you for clarifying this. Makes sense to me.
> 
>>    to do a better show, all which rely on the output of show being parseable as Haskel code.
> 
> Is it guaranteed that the derived show instances all produce parsable
> Haskel code? I could not find such a guarantee in the Haskell report.


There's no "thou shalt" regarding user defined Read/Show instances, but note these comments from 
http://www.haskell.org/onlinereport/haskell2010/haskellch11.html#x18-18600011.4
about the derived instances of Read and Show:

  - 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.

So, it would seem to make sense to follow the spirit of the built-in instances.
 
> 
>>> 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?
> 
> I still need to know the answer to this. If I got you right, you would
> like to see all ad-hoc show instances removed, right?

That's exactly right, I'd like to see all of them removed.
(But maybe we need another class 'ConciseShow'---or the like---so as not to throw away the code that previously showed these values.)

All the best,

Mark

> 
> Greetings
> 
> Alex
> 
> PS: did you intentionally not reply to the list?

P.S., It looks I *did* cc the list. :-)




More information about the Language-c mailing list