module Algebra.Real (
C(abs, signum),
) where
import qualified Algebra.Ring as Ring
import qualified Algebra.Additive as Additive
import qualified Algebra.ZeroTestable as ZeroTestable
import Algebra.Ring (one, )
import Algebra.Additive (zero, negate,)
import PreludeBase
import Prelude(Int,Integer,Float,Double)
class (Ring.C a, ZeroTestable.C a, Ord a) => C a where
abs :: a -> a
signum :: a -> a
abs x = max x (negate x)
signum x = case compare x zero of
GT -> one
EQ -> zero
LT -> negate one
instance C Integer
instance C Int
instance C Float
instance C Double