Bug in show instance

Sigbjorn Finne sof@galois.com
Fri, 22 Mar 2002 09:29:31 -0800


ok, based on the :settings you were using, there's a couple of
things going on here:

* you were using the internal printer to print results and
   not "show", which explains why your Show instance isn't
   being used (you control whether or not to use "show" to
   print results via the 'u' toggle.)

* the internal printer doesn't print out the 'tag' of a newtype
   value, as that piece of information is by then gone. This is
   arguably a printer bug, but I'm not proposing/volunteering
   to fix it (at least not right now.)

hth
--sigbjorn

----- Original Message -----
From: "Shawn P. Garbett" <Shawn@Garbett.org>
To: <hugs-bugs@haskell.org>
Cc: "Dean Herington" <heringto@cs.unc.edu>
Sent: Thursday, January 31, 2002 06:39
Subject: Bug in show instance

>
> The following code generates some unexpected behavior (at least to me) in
> hugs (Feburary 2001: hugs 98 compatibility)
>
> - -----------------------------------
> main = print(show test)
>
> newtype Out a = MkOut (String, a)
>
> instance (Show a) => Show (Out a) where
>   show (MkOut (x,y)) = x ++ " value: " ++ show y
>
> test = MkOut("Blah\nBlah", 4)
> - --------------------------------------
>
> Hugs Output:
>
> Main> test
> ("Blah\nBlah",4)
> (20 reductions, 55 cells)
> Main>
>
> - ------------------------------
>
> GHCi (and expected output):
>
> Main> test
> Blah
> Blah value: 4
> Main>
>