Revised numerical prelude, version 0.02
Marcin 'Qrczak' Kowalczyk
14 Feb 2001 21:53:16 GMT
Tue, 13 Feb 2001 18:32:21 -0500, Dylan Thurston <firstname.lastname@example.org> pisze:
> Here's a revision of the numerical prelude.
I like it!
> > class (Real a, Floating a) => RealFrac a where
> > -- lifted directly from Haskell 98 Prelude
> > properFraction :: (Integral b) => a -> (b,a)
> > truncate, round :: (Integral b) => a -> b
> > ceiling, floor :: (Integral b) => a -> b
These should be SmallIntegral.
> For an instance of RealIntegral a, it is expected that a `quot` b
> will round towards minus infinity and a `div` b will round towards 0.
> > class (Real a) => SmallReal a where
> > toRational :: a -> Rational
> > class (SmallReal a, RealIntegral a) => SmallIntegral a where
> > toInteger :: a -> Integer
> These two classes exist to allow convenient conversions, primarily
> between the built-in types. These classes are "small" in the sense
> that they can be converted to integers (resp. rationals) without loss
> of information.
I find names of these classes unclear: Integer is not small integral,
it's big integral (as opposed to Int)! :-)
Perhaps these classes should be called Real and Integral, with
different names for current Real and Integral. But I don't have
a concrete proposal.
__("< Marcin Kowalczyk * email@example.com http://qrczak.ids.net.pl/
^^ SYGNATURA ZASTĘPCZA