@@ -203,22 +203,33 @@ interface Num ty => Neg ty where
203 ||| The underlying of unary minus. `-5` desugars to `negate (fromInteger 5)`.
203 ||| The underlying of unary minus. `-5` desugars to `negate (fromInteger 5)`.
204 negate : ty -> ty
204 negate : ty -> ty
205 (-) : ty -> ty -> ty
205 (-) : ty -> ty -> ty
206− ||| Absolute value
206+
209Neg Integer where
208Neg Integer where
210 negate x = prim__subBigInt 0 x
209 negate x = prim__subBigInt 0 x
211 (-) = prim__subBigInt
210 (-) = prim__subBigInt
212− abs x = if x < 0 then -x else x
214Neg Int where
212Neg Int where
215 negate x = prim__subInt 0 x
213 negate x = prim__subInt 0 x
216 (-) = prim__subInt
214 (-) = prim__subInt
217− abs x = if x < (prim__truncBigInt_Int 0) then -x else x
219Neg Double where
216Neg Double where
220 negate x = prim__negFloat x
217 negate x = prim__negFloat x
221 (-) = prim__subFloat
218 (-) = prim__subFloat
220+-- ---------------------------------------------------- [ Absolute Value Interface ]
221+||| Numbers for which the absolute value is defined should implement `Abs`.
222+interface Num ty => Abs ty where
227+ abs x = if x < 0 then -x else x
230+ abs x = if x < (prim__truncBigInt_Int 0) then -x else x
222 abs x = if x < (prim__toFloatBigInt 0) then -x else x
233 abs x = if x < (prim__toFloatBigInt 0) then -x else x
224-- ------------------------------------------------------------
235-- ------------------------------------------------------------