Numeric Classes Quibble

Ashley Yakeley ashley@semantic.org
Tue, 9 Apr 2002 17:45:07 -0700


At 2002-04-09 08:52, Alastair Reid wrote:

>> Currently 'floor' doesn't work on Integers. I think this is undesirable.
>
>I missed the motivation - can you elaborate?

I'd like to be able to write polymorphic numeric functions over Real. 
Here's the snippet that gave rise to this:

    instance (HasLeapSecondsRule m,Real a) =>
     MonadIsA m (UTCTime a) (Time a) where
        {
        getConvert (MkPointWrapper t) = do
            {
            lsr <- getLeapSecondsRule;
            let
                {
                days = invertFuncWithApprox lsr (floor (toRational t)) 
(intdiv t 86400.002); -- 2ms approx
                secs = t - fromInteger (lsr days);
                };
            return (MkUTCTime days secs);
            };
        };

I'm using a fairly trivial workaround, (floor (toRational t)). But 
ideally I could just write (floor t).

>Or, to put it another way, wouldn't floor always act as the identity?

Not over all Real, obviously.

>What would this buy us?

Generality?

-- 
Ashley Yakeley, Seattle WA