Rationals
Sigbjorn Finne
sof@galconn.com
Sun, 29 Jul 2001 11:57:48 -0700
Amanda Clare ajc@aber.ac.uk writes:
>
> Does anyone know how I use Rationals in ghc? In nhc I can just write
>
> let a = b % c
>
> But ghc-5.00.2 gives the error message "Variable not in scope: `%'"
>
> I've looked through the documentation and can't find any reference to a
> Rational library, or any other library that might have it. The package
> "std" has a Ratio.hi in the lib/imports directory (std isn't described
> in the documentation) but including this doesn't help - same error.
As you noticed, you need to import Ratio to get at % -- GHC gets this
right wrt the Haskell98 report. Hugs exports it from the Prelude (as
does NHC, by the looks of it), which used to be right, but isn't in H98.
This could be trivially fixed on the Hugs side, but I'm not sure the
resulting breakage would be worth it.
> The Haskell98 report says:
> "In particular, the type Rational is a ratio of two Integer values, as
> defined in the Rational library."
That's a typo in the Report, it should say the "Ratio library"
(Section 6.4, Simon).
--sigbjorn