@@ -11,7 +11,7 @@ infixl 7 <<, >>
11infixl 8 +,-
11infixl 8 +,-
12infixl 9 *,/
12infixl 9 *,/
14−-- ------------------------------------------------------- [ Numeric Operators ]
14+-- ------------------------------------------------------------- [ Boolean Ops ]
15intToBool : Int -> Bool
15intToBool : Int -> Bool
16intToBool 0 = False
16intToBool 0 = False
17intToBool x = True
17intToBool x = True
@@ -19,6 +19,7 @@ intToBool x = True
19boolOp : (a -> a -> Int) -> a -> a -> Bool
19boolOp : (a -> a -> Int) -> a -> a -> Bool
20boolOp op x y = intToBool (op x y)
20boolOp op x y = intToBool (op x y)
22+-- ---------------------------------------------------------- [ Equality Class ]
22-- | The Eq class defines inequality and equality.
23-- | The Eq class defines inequality and equality.
23class Eq a where
24class Eq a where
24 (==) : a -> a -> Bool
25 (==) : a -> a -> Bool
@@ -47,11 +48,12 @@ instance Eq Bool where
47 True == False = False
48 True == False = False
48 False == True = False
49 False == True = False
49 False == False = True
50 False == False = True
51instance (Eq a, Eq b) => Eq (a, b) where
52instance (Eq a, Eq b) => Eq (a, b) where
52 (==) (a, c) (b, d) = (a == b) && (c == d)
53 (==) (a, c) (b, d) = (a == b) && (c == d)
56+-- ---------------------------------------------------------- [ Ordering Class ]
55data Ordering = LT | EQ | GT
57data Ordering = LT | EQ | GT
57instance Eq Ordering where
59instance Eq Ordering where
@@ -123,6 +125,7 @@ instance (Ord a, Ord b) => Ord (a, b) where
123 then compare xl yl
125 then compare xl yl
124 else compare xr yr
126 else compare xr yr
128+-- --------------------------------------------------------- [ Numerical Class ]
126-- | The Num class defines basic numerical arithmetic.
129-- | The Num class defines basic numerical arithmetic.
127class Num a where
130class Num a where
128 (+) : a -> a -> a
131 (+) : a -> a -> a
@@ -234,17 +237,86 @@ instance Ord Bits64 where
234 else if l > r then GT
237 else if l > r then GT
237−-- | Integer division.
239−div : Integer -> Integer -> Integer
240−div = prim__sdivBigInt
242−-- | Integer modulus.
241+-- ------------------------------------------------------------- [ Fractionals ]
244−mod : Integer -> Integer -> Integer
245−mod = prim__sremBigInt
247-- | Fractional division of two Floats.
243-- | Fractional division of two Floats.
248(/) : Float -> Float -> Float
244(/) : Float -> Float -> Float
249(/) = prim__divFloat
245(/) = prim__divFloat
248+-- --------------------------------------------------------------- [ Integrals ]
251+class Integral a where
255+-- ---------------------------------------------------------------- [ Integers ]
256+divBigInt : Integer -> Integer -> Integer
257+divBigInt = prim__sdivBigInt
259+modBigInt : Integer -> Integer -> Integer
260+modBigInt = prim__sremBigInt
262+instance Integral Integer where
266+-- --------------------------------------------------------------------- [ Int ]
268+divInt : Int -> Int -> Int
269+divInt = prim__sdivInt
271+modInt : Int -> Int -> Int
272+modInt = prim__sremInt
274+instance Integral Int where
278+-- ------------------------------------------------------------------- [ Bits8 ]
279+divB8 : Bits8 -> Bits8 -> Bits8
282+modB8 : Bits8 -> Bits8 -> Bits8
285+instance Integral Bits8 where
289+-- ------------------------------------------------------------------ [ Bits16 ]
290+divB16 : Bits16 -> Bits16 -> Bits16
291+divB16 = prim__sdivB16
293+modB16 : Bits16 -> Bits16 -> Bits16
294+modB16 = prim__sremB16
296+instance Integral Bits16 where
300+-- ------------------------------------------------------------------ [ Bits32 ]
301+divB32 : Bits32 -> Bits32 -> Bits32
302+divB32 = prim__sdivB32
304+modB32 : Bits32 -> Bits32 -> Bits32
305+modB32 = prim__sremB32
307+instance Integral Bits32 where
311+-- ------------------------------------------------------------------ [ Bits64 ]
312+divB64 : Bits64 -> Bits64 -> Bits64
313+divB64 = prim__sdivB64
315+modB64 : Bits64 -> Bits64 -> Bits64
316+modB64 = prim__sremB64
318+instance Integral Bits64 where