Joachim Korittky writes:
>
> The following program shows a difference in Show and Read
> between ghc and Hugs:
>
>
> module Main where
>
> data Fields = Fields { i::Int }
> deriving(Show, Read)
>
> data Foo = Foo Fields
> deriving(Show, Read)
>
> foo = Foo Fields{ i=0 }
>
> main = putStr (show foo)
>
>
> In ghc 3.0 (didn't try 3.01 yet) it leads to
>
> Foo (Fields{i=0})
>
> Hugs Jan 1998 shows
>
> Foo Fields{i=0}
>
> which is as I think the expected result.
>
Hi,
I agree they should be the same, but this is murky waters
Report-wise. Previous versions of the Haskell Report gave the rule for
the derived showsPrec function on a data type, but the 1.4 Report
doesn't seem to have this (at least I wasn't able to find it in the
on-line version.)
Assuming the old rule still holds, components of a data constructor
are all shown with (showsPrec 10), then I don't see how the derived
instance generated by GHC breaks the spec here. (With (showsPrec 10),
you can only drop the parenthesis if the value is atomic, which I
claim a labelled field constructor is not.)
With Hugs, are you able to `read' back in again the result of
(show foo) ?
--Sigbjorn