% ------------------------------------------------------------------------------
-% $Id: Real.lhs,v 1.1 2001/06/28 14:15:03 simonmar Exp $
+% $Id: Real.lhs,v 1.3 2002/02/12 15:51:26 simonmar Exp $
%
% (c) The University of Glasgow, 1994-2000
%
\begin{code}
reduce :: (Integral a) => a -> a -> Ratio a
+{-# SPECIALISE reduce :: Integer -> Integer -> Rational #-}
reduce _ 0 = error "Ratio.%: zero denominator"
reduce x y = (x `quot` d) :% (y `quot` d)
where d = gcd x y
instance (Integral a) => Fractional (Ratio a) where
{-# SPECIALIZE instance Fractional Rational #-}
(x:%y) / (x':%y') = (x*y') % (y*x')
- recip (x:%y) = if x < 0 then (-y) :% (-x) else y :% x
+ recip (x:%y) = y % x
fromRational (x:%y) = fromInteger x :% fromInteger y
instance (Integral a) => Real (Ratio a) where
{-# RULES
"realToFrac/Int->Int" realToFrac = id :: Int -> Int
#-}
-
--- For backward compatibility
-{-# DEPRECATED fromInt "use fromIntegral instead" #-}
-fromInt :: Num a => Int -> a
-fromInt = fromIntegral
-
--- For backward compatibility
-{-# DEPRECATED toInt "use fromIntegral instead" #-}
-toInt :: Integral a => a -> Int
-toInt = fromIntegral
\end{code}
%*********************************************************