@@ -203,22 +203,33 @@ interface Num ty => Neg ty where
203203 ||| The underlying of unary minus. `-5` desugars to `negate (fromInteger 5)`.
204204 negate : ty -> ty
205205 (-) : ty -> ty -> ty
206− ||| Absolute value
207− abs : ty -> ty
206+
208207
209208Neg Integer where
210209 negate x = prim__subBigInt 0 x
211210 (-) = prim__subBigInt
212− abs x = if x < 0 then -x else x
213211
214212Neg Int where
215213 negate x = prim__subInt 0 x
216214 (-) = prim__subInt
217− abs x = if x < (prim__truncBigInt_Int 0) then -x else x
218215
219216Neg Double where
220217 negate x = prim__negFloat x
221218 (-) = prim__subFloat
219+
220+-- ---------------------------------------------------- [ Absolute Value Interface ]
221+||| Numbers for which the absolute value is defined should implement `Abs`.
222+interface Num ty => Abs ty where
223+ ||| Absolute value
224+ abs : ty -> ty
225+
226+Abs Integer where
227+ abs x = if x < 0 then -x else x
228+
229+Abs Int where
230+ abs x = if x < (prim__truncBigInt_Int 0) then -x else x
231+
232+Abs Double where
222233 abs x = if x < (prim__toFloatBigInt 0) then -x else x
223234
224235-- ------------------------------------------------------------