Skip to content

Show instance for Ratio is wrong

GHCi> :m Data.Ratio
GHCi> show (1%2)
"1%2"

Hugs> :l Data.Ratio
Hugs> show (1%2)
"1 % 2"

The Haskell report specifies (http://haskell.org/onlinereport/ratio.html):

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

This effects the nofib suite, where the expected.stdout files are based on GHC's incorrect Ratio implementation.

Tested only on 6.6.1.

Edited by Ian Lynagh -
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information