17 {-# OPTIONS -fglasgow-exts -fno-implicit-prelude #-}
21 import {-# SOURCE #-} PrelErr
30 default () -- Double isn't available yet,
31 -- and we shouldn't be using defaults anyway
41 class (Eq a, Show a) => Num a where
42 (+), (-), (*) :: a -> a -> a
45 fromInteger :: Integer -> a
46 fromInt :: Int -> a -- partain: Glasgow extension
50 fromInt (I# i#) = fromInteger (S# i#)
51 -- Go via the standard class-op if the
52 -- non-standard one ain't provided
58 subtract :: (Num a) => a -> a -> a
59 {-# INLINE subtract #-}
63 ord_0 = fromInt (ord '0')
74 instance Num Int where
76 (-) x y = minusInt x y
77 negate x = negateInt x
78 (*) x y = timesInt x y
79 abs n = if n `geInt` 0 then n else (negateInt n)
81 signum n | n `ltInt` 0 = negateInt 1
90 -- These can't go in PrelBase with the defn of Int, because
91 -- we don't have pairs defined at that time!
93 quotRemInt :: Int -> Int -> (Int, Int)
94 a@(I# _) `quotRemInt` b@(I# _) = (a `quotInt` b, a `remInt` b)
95 -- OK, so I made it a little stricter. Shoot me. (WDP 94/10)
97 divModInt :: Int -> Int -> (Int, Int)
98 divModInt x@(I# _) y@(I# _) = (x `divInt` y, x `modInt` y)
99 -- Stricter. Sorry if you don't like it. (WDP 94/10)
111 = S# Int# -- small integers
112 | J# Int# ByteArray# -- large integers
118 zeroInteger :: Integer