on master help sign in
made Num not a subclass of Ord and Eq, instead only of Eq such that complex numbers, for example, don't have to be ordered.
commit7ccc101161f88742b18e8c02966e836dae0df6eb authorMekeor Melire <mekeor@ymail.com> dateSat 25 Feb 2012, 15:59 (15 years ago) parenta3c760f
1 file changed+4−3
lib/builtins.idr+4−3
lib/builtins.idr+4−3
@@ -186,14 +186,12 @@ instance (Ord a, Ord b) => Ord (a, b) where
186186 else compare xr yr
187187
188188
189−class (Eq a, Ord a) => Num a where
189+class Eq a => Num a where
190190 (+) : a -> a -> a
191191 (-) : a -> a -> a
192192 (*) : a -> a -> a
193193
194194 abs : a -> a
195− abs x = if (x < 0) then (-x) else x
196−
197195 fromInteger : Int -> a
198196
199197
@@ -204,6 +202,7 @@ instance Num Int where
204202 (*) = prim__mulInt
205203
206204 fromInteger = id
205+ abs x = if x<0 then -x else x
207206
208207
209208instance Num Integer where
@@ -211,6 +210,7 @@ instance Num Integer where
211210 (-) = prim__subBigInt
212211 (*) = prim__mulBigInt
213212
213+ abs x = if x<0 then -x else x
214214 fromInteger = prim__intToBigInt
215215
216216
@@ -219,6 +219,7 @@ instance Num Float where
219219 (-) = prim__subFloat
220220 (*) = prim__mulFloat
221221
222+ abs x = if x<0 then -x else x
222223 fromInteger = prim__intToFloat
223224
224225