| However, I would guess that changing the type signature of
| the current showInt function is unacceptable for Haskell'98.
| Maybe we should consider adding the more general version
| under a new name like showIntBase, together with
| show{Dec,Oct,Hex}? This would break no existing code,
As you say, we can't change the type of showInt. I suppose we could
add:
showIntAtBase :: Integral a=20
=3D a-- base
- (a - Char) -- digit to char
- a-- number to show.
- ShowS
showOct, showHex :: Integral a =3D
Also, GHC's NumExts has
doubleToFloat :: Double - Float
floatToDouble :: Float - Double
Q2: If we are going to run round adding functions to Numeric,
should we add those too? It's hard to know where to stop... but if
that conversion is what you want to do, H98 doesn't give a good
There is something strange about the Haskell'98 Numeric library,
which I think could be considered a bug of sorts. There are functions
readDec, readOct, readHex :: (Integral a) = ReadS a
which read an integer from a string in base 10, 8, or 16, but there
are no corresponding show functions
There is something strange about the Haskell'98 Numeric library,
which I think could be considered a bug of sorts. There are functions
readDec, readOct, readHex :: (Integral a) = ReadS a
which read an integer from a string in base 10, 8, or 16, but there
are no corresponding show
Hi!
In fact, we might want to be slightly more general. Why don't go for
a general base conversion, much like Malcolms idea but without converting
every digit to a Char. Say something like
toBase :: (Integral a) = a - a - [a]
toBase base n
| n 0 = error Numeric.toBase: can't