on master help sign in
Remove Eq constraint from Num
a94fd81Edwin Brady
idris.cabal+1−1
@@ -1,5 +1,5 @@
1Name: idris
1Name: idris
2−Version: 0.9.2
2+Version: 0.9.3
3License: BSD3
3License: BSD3
4License-file: LICENSE
4License-file: LICENSE
5Author: Edwin Brady
5Author: Edwin Brady
lib/builtins.idr+1−1
@@ -192,7 +192,7 @@ instance (Ord a, Ord b) => Ord (a, b) where
192 else compare xr yr
192 else compare xr yr
193
193
194
194
195−class Eq a => Num a where
195+class Num a where
196 (+) : a -> a -> a
196 (+) : a -> a -> a
197 (-) : a -> a -> a
197 (-) : a -> a -> a
198 (*) : a -> a -> a
198 (*) : a -> a -> a
samples/interp.idr+3−7
@@ -48,19 +48,15 @@ using (G : Vect Ty n)
48 (==) : Expr G TyInt -> Expr G TyInt -> Expr G TyBool
48 (==) : Expr G TyInt -> Expr G TyInt -> Expr G TyBool
49 (==) = Op (==)
49 (==) = Op (==)
50
50
51− -- Some dummy instances for Num overloading
51+ (<) : Expr G TyInt -> Expr G TyInt -> Expr G TyBool
52− instance Eq (Expr G TyInt) where
52+ (<) = Op (<)
53− (==) x y = False
54−
55− instance Ord (Expr G TyInt) where
56− compare x y = EQ
57
53
58 instance Num (Expr G TyInt) where
54 instance Num (Expr G TyInt) where
59 (+) x y = Op (+) x y
55 (+) x y = Op (+) x y
60 (-) x y = Op (-) x y
56 (-) x y = Op (-) x y
61 (*) x y = Op (*) x y
57 (*) x y = Op (*) x y
62
58
63− abs x = If (Op (<) x (Val 0)) (Op (-) 0 x) x
59+ abs x = IF (x < 0) THEN (-x) ELSE x
64
60
65 fromInteger = Val . fromInteger
61 fromInteger = Val . fromInteger
66
62