@@ -11,7 +11,7 @@ infixl 7 <<, >>
1111infixl 8 +,-
1212infixl 9 *,/
1313
14−-- ------------------------------------------------------- [ Numeric Operators ]
14+-- ------------------------------------------------------------- [ Boolean Ops ]
1515intToBool : Int -> Bool
1616intToBool 0 = False
1717intToBool x = True
@@ -19,6 +19,7 @@ intToBool x = True
1919boolOp : (a -> a -> Int) -> a -> a -> Bool
2020boolOp op x y = intToBool (op x y)
2121
22+-- ---------------------------------------------------------- [ Equality Class ]
2223-- | The Eq class defines inequality and equality.
2324class Eq a where
2425 (==) : a -> a -> Bool
@@ -47,11 +48,12 @@ instance Eq Bool where
4748 True == False = False
4849 False == True = False
4950 False == False = True
50−
51+
5152instance (Eq a, Eq b) => Eq (a, b) where
5253 (==) (a, c) (b, d) = (a == b) && (c == d)
5354
5455
56+-- ---------------------------------------------------------- [ Ordering Class ]
5557data Ordering = LT | EQ | GT
5658
5759instance Eq Ordering where
@@ -123,6 +125,7 @@ instance (Ord a, Ord b) => Ord (a, b) where
123125 then compare xl yl
124126 else compare xr yr
125127
128+-- --------------------------------------------------------- [ Numerical Class ]
126129-- | The Num class defines basic numerical arithmetic.
127130class Num a where
128131 (+) : a -> a -> a
@@ -234,17 +237,86 @@ instance Ord Bits64 where
234237 else if l > r then GT
235238 else EQ
236239
237−-- | Integer division.
238−partial
239−div : Integer -> Integer -> Integer
240−div = prim__sdivBigInt
241240
242−-- | Integer modulus.
243−partial
244−mod : Integer -> Integer -> Integer
245−mod = prim__sremBigInt
241+-- ------------------------------------------------------------- [ Fractionals ]
246242
247243-- | Fractional division of two Floats.
248244(/) : Float -> Float -> Float
249245(/) = prim__divFloat
250246
247+
248+-- --------------------------------------------------------------- [ Integrals ]
249+%default partial
250+
251+class Integral a where
252+ div : a -> a -> a
253+ mod : a -> a -> a
254+
255+-- ---------------------------------------------------------------- [ Integers ]
256+divBigInt : Integer -> Integer -> Integer
257+divBigInt = prim__sdivBigInt
258+
259+modBigInt : Integer -> Integer -> Integer
260+modBigInt = prim__sremBigInt
261+
262+instance Integral Integer where
263+ div = divBigInt
264+ mod = modBigInt
265+
266+-- --------------------------------------------------------------------- [ Int ]
267+
268+divInt : Int -> Int -> Int
269+divInt = prim__sdivInt
270+
271+modInt : Int -> Int -> Int
272+modInt = prim__sremInt
273+
274+instance Integral Int where
275+ div = divInt
276+ mod = modInt
277+
278+-- ------------------------------------------------------------------- [ Bits8 ]
279+divB8 : Bits8 -> Bits8 -> Bits8
280+divB8 = prim__sdivB8
281+
282+modB8 : Bits8 -> Bits8 -> Bits8
283+modB8 = prim__sremB8
284+
285+instance Integral Bits8 where
286+ div = divB8
287+ mod = modB8
288+
289+-- ------------------------------------------------------------------ [ Bits16 ]
290+divB16 : Bits16 -> Bits16 -> Bits16
291+divB16 = prim__sdivB16
292+
293+modB16 : Bits16 -> Bits16 -> Bits16
294+modB16 = prim__sremB16
295+
296+instance Integral Bits16 where
297+ div = divB16
298+ mod = modB16
299+
300+-- ------------------------------------------------------------------ [ Bits32 ]
301+divB32 : Bits32 -> Bits32 -> Bits32
302+divB32 = prim__sdivB32
303+
304+modB32 : Bits32 -> Bits32 -> Bits32
305+modB32 = prim__sremB32
306+
307+instance Integral Bits32 where
308+ div = divB32
309+ mod = modB32
310+
311+-- ------------------------------------------------------------------ [ Bits64 ]
312+divB64 : Bits64 -> Bits64 -> Bits64
313+divB64 = prim__sdivB64
314+
315+modB64 : Bits64 -> Bits64 -> Bits64
316+modB64 = prim__sremB64
317+
318+instance Integral Bits64 where
319+ div = divB64
320+ mod = modB64
321+
322+