\begin{code}
-{-# OPTIONS_GHC -XNoImplicitPrelude #-}
+{-# LANGUAGE CPP, NoImplicitPrelude, MagicHash, UnboxedTuples #-}
{-# OPTIONS_HADDOCK hide #-}
-----------------------------------------------------------------------------
-- |
\begin{code}
-- | Rational numbers, with numerator and denominator of some 'Integral' type.
-data (Integral a) => Ratio a = !a :% !a deriving (Eq)
+data Ratio a = !a :% !a deriving (Eq)
-- | Arbitrary-precision rational numbers, represented as a ratio of
-- two 'Integer' values. A rational number may be constructed using
a `quot` b
| b == 0 = divZeroError
- | a == minBound && b == (-1) = overflowError
+ | b == (-1) && a == minBound = overflowError -- Note [Order of tests]
+ -- in GHC.Int
| otherwise = a `quotInt` b
a `rem` b
| b == 0 = divZeroError
- | a == minBound && b == (-1) = overflowError
+ | b == (-1) && a == minBound = overflowError -- Note [Order of tests]
+ -- in GHC.Int
| otherwise = a `remInt` b
a `div` b
| b == 0 = divZeroError
- | a == minBound && b == (-1) = overflowError
+ | b == (-1) && a == minBound = overflowError -- Note [Order of tests]
+ -- in GHC.Int
| otherwise = a `divInt` b
a `mod` b
| b == 0 = divZeroError
- | a == minBound && b == (-1) = overflowError
+ | b == (-1) && a == minBound = overflowError -- Note [Order of tests]
+ -- in GHC.Int
| otherwise = a `modInt` b
a `quotRem` b
| b == 0 = divZeroError
- | a == minBound && b == (-1) = overflowError
+ | b == (-1) && a == minBound = overflowError -- Note [Order of tests]
+ -- in GHC.Int
| otherwise = a `quotRemInt` b
a `divMod` b
| b == 0 = divZeroError
- | a == minBound && b == (-1) = overflowError
+ | b == (-1) && a == minBound = overflowError -- Note [Order of tests]
+ -- in GHC.Int
| otherwise = a `divModInt` b
\end{code}