@@ -28,14 +28,6 @@ public
28intToMod : {n : Nat} -> Int -> Mod2 n
28intToMod : {n : Nat} -> Int -> Mod2 n
29intToMod {n=n} x = MkMod2 (intToBits x)
29intToMod {n=n} x = MkMod2 (intToBits x)
32−modToBits : Mod2 n -> Bits n
33−modToBits (MkMod2 x) = x
36−bitsToMod : Bits n -> Mod2 n
37−bitsToMod x = MkMod2 x
39instance Eq (Mod2 n) where
31instance Eq (Mod2 n) where
40 (==) = modComp (==)
32 (==) = modComp (==)
@@ -54,10 +46,10 @@ instance Num (Mod2 n) where
54 fromInteger = intToMod
46 fromInteger = intToMod
56instance Cast (Mod2 n) (Bits n) where
48instance Cast (Mod2 n) (Bits n) where
57− cast = modToBits
49+ cast (MkMod2 x) = x
59instance Cast (Bits n) (Mod2 n) where
51instance Cast (Bits n) (Mod2 n) where
60− cast = bitsToMod
52+ cast x = MkMod2 x
62-- TODO: Other bases
54-- TODO: Other bases
@@ -66,5 +58,5 @@ modToStr x = pack (reverse (helper x))
67 %assert_total
59 %assert_total
68 helper : Mod2 n -> List Char
60 helper : Mod2 n -> List Char
69− helper x = strIndex "0123456789" (bitsToInt (modToBits (x `rem` 10)))
61+ helper x = strIndex "0123456789" (bitsToInt (cast (x `rem` 10)))
70 :: (if x < 10 then [] else helper (x `div` 10))
62 :: (if x < 10 then [] else helper (x `div` 10))