Ord(..),
Enum(..),
Bounded(..),
- Num((+), (-), (*), negate, abs, signum, fromInteger, fromInt{-glaExt-}),
+ Num((+), (-), (*), negate, abs, signum, fromInteger),
+ -- The fromInt method is exposed only by GlaExts
Real(..),
- Integral(quot, rem, div, mod, quotRem, divMod, toInteger, toInt{-partain-}),
+ Integral(quot, rem, div, mod, quotRem, divMod, toInteger),
+ -- The toInt method is exposed only by GlaExts
Fractional(..),
Floating(..),
RealFrac(..),
import PrelRead
import PrelEnum
import PrelNum
-import PrelNumExtra
+import PrelReal
+import PrelFloat
import PrelTup
import PrelMaybe
import PrelShow
\end{code}
+%*********************************************************
+%* *
+\subsection{List sum and product}
+%* *
+%*********************************************************
+
List sum and product are defined here because PrelList is too far
down the compilation chain to "see" the Num class.
prod (x:xs) a = prod xs (a*x)
#endif
\end{code}
+
+
+%*********************************************************
+%* *
+\subsection{Coercions}
+%* *
+%*********************************************************
+
+\begin{code}
+{-# SPECIALIZE fromIntegral ::
+ Int -> Rational,
+ Integer -> Rational,
+ Int -> Int,
+ Int -> Integer,
+ Int -> Float,
+ Int -> Double,
+ Integer -> Int,
+ Integer -> Integer,
+ Integer -> Float,
+ Integer -> Double #-}
+fromIntegral :: (Integral a, Num b) => a -> b
+fromIntegral = fromInteger . toInteger
+
+{-# SPECIALIZE realToFrac ::
+ Double -> Rational,
+ Rational -> Double,
+ Float -> Rational,
+ Rational -> Float,
+ Rational -> Rational,
+ Double -> Double,
+ Double -> Float,
+ Float -> Float,
+ Float -> Double #-}
+realToFrac :: (Real a, Fractional b) => a -> b
+realToFrac = fromRational . toRational
+\end{code}