[Haskell-cafe] Showing Data.Ratio - different on GHC vs Hugs/Yhc

2007-11-16 Thread Neil Mitchell
Hi

Under Hugs and Yhc, showing a Ratio 1%2 gives 1 % 2. Under GHC
showing 1%2 gives 1%2. Does the standard say anything about this? Is
someone wrong? And how do Yhc/nhc/Hugs pass Bernouilli in the Nofib
suite given that the output doesn't match?

Thanks

Neil
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Showing Data.Ratio - different on GHC vs Hugs/Yhc

2007-11-16 Thread David Menendez
On Nov 16, 2007 2:12 PM, Neil Mitchell [EMAIL PROTECTED] wrote:
 Under Hugs and Yhc, showing a Ratio 1%2 gives 1 % 2. Under GHC
 showing 1%2 gives 1%2. Does the standard say anything about this? Is
 someone wrong? And how do Yhc/nhc/Hugs pass Bernouilli in the Nofib
 suite given that the output doesn't match?

Judging by the Read instance, the whitespace isn't considered significant.

Prelude Data.Ratio map read [1%2, 1 % 2,  1   %   2 ] :: [Rational]
[1%2,1%2,1%2]


-- 
Dave Menendez [EMAIL PROTECTED]
http://www.eyrie.org/~zednenem/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Showing Data.Ratio - different on GHC vs Hugs/Yhc

2007-11-16 Thread Twan van Laarhoven

Neil Mitchell wrote:


Hi

Under Hugs and Yhc, showing a Ratio 1%2 gives 1 % 2. Under GHC
showing 1%2 gives 1%2. Does the standard say anything about this? Is
someone wrong?


Yes, ghc is wrong here, the Haskell 98 report [1] specifies:

instance  (Integral a)  = Show (Ratio a)  where
showsPrec p (x:%y)  =  showParen (p  ratPrec)
   (showsPrec (ratPrec+1) x .
showString  %  .
showsPrec (ratPrec+1) y)

While it doesn't really matter, it is a deviation from the standard.

I would personally prefer it if rationals were shown as 1%2, because 
the space is not needed, and other show instances such as lists don't 
insert spaces either.


[1]: http://haskell.org/onlinereport/ratio.html

Twan
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe