X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=GHC%2FReal.lhs;h=971f2767b655b14f94255486a520f1b5a65f3106;hb=d71ca65be98abb12afa1dfc2815e6e157799ffdc;hp=fdce8b94361b7b91cd5836853eb94e69a783ea2d;hpb=0a382bb76f5a25bbbb6e6847c916cfd127d1ecf4;p=ghc-base.git diff --git a/GHC/Real.lhs b/GHC/Real.lhs index fdce8b9..971f276 100644 --- a/GHC/Real.lhs +++ b/GHC/Real.lhs @@ -133,10 +133,15 @@ class (Real a, Enum a) => Integral a where -- | conversion to 'Integer' toInteger :: a -> Integer + {-# INLINE quot #-} + {-# INLINE rem #-} + {-# INLINE div #-} + {-# INLINE mod #-} n `quot` d = q where (q,_) = quotRem n d n `rem` d = r where (_,r) = quotRem n d n `div` d = q where (q,_) = divMod n d n `mod` d = r where (_,r) = divMod n d + divMod n d = if signum r == negate (signum d) then (q-1, r+d) else qr where qr@(q,r) = quotRem n d @@ -154,6 +159,8 @@ class (Num a) => Fractional a where -- @('Fractional' a) => a@. fromRational :: Rational -> a + {-# INLINE recip #-} + {-# INLINE (/) #-} recip x = 1 / x x / y = x * recip y @@ -182,6 +189,7 @@ class (Real a, Fractional a) => RealFrac a where -- | @'floor' x@ returns the greatest integer not greater than @x@ floor :: (Integral b) => a -> b + {-# INLINE truncate #-} truncate x = m where (m,_) = properFraction x round x = let (n,r) = properFraction x @@ -456,9 +464,6 @@ lcm x y = abs ((x `quot` (gcd x y)) * y) "lcm/Integer->Integer->Integer" lcm = lcmInteger #-} --- XXX to use another Integer implementation, you might need to disable --- the gcd/Integer and lcm/Integer RULES above --- gcdInteger' :: Integer -> Integer -> Integer gcdInteger' 0 0 = error "GHC.Real.gcdInteger': gcd 0 0 is undefined" gcdInteger' a b = gcdInteger a b