numeric-prelude-0.1.3: An experimental alternative hierarchy of numeric type classesSource codeContentsIndex
class (C a, C a, Ord a) => C a where
abs :: a -> a
signum :: a -> a
class (C a, C a, Ord a) => C a whereSource

This is the type class of an ordered ring, satisfying the laws

              a * b === b * a
      a + (max b c) === max (a+b) (a+c)
   negate (max b c) === min (negate b) (negate c)
      a * (max b c) === max (a*b) (a*c) where a >= 0

Note that abs is in a rather different place than it is in the Haskell 98 Prelude. In particular,

   abs :: Complex -> Complex

is not defined. To me, this seems to have the wrong type anyway; Complex.magnitude has the correct type.

Note: The abs function can be defined for Additive and Ord, the Ring constraint is not needed. We may move signum to the new RealRing class.

abs :: a -> aSource
signum :: a -> aSource
show/hide Instances
C Double
C Float
C Int
C Int8
C Int16
C Int32
C Int64
C Integer
C Word
C Word8
C Word16
C Word32
C Word64
(C a, C a) => C (T a)
(C a, C a) => C (T a)
(C a, C a, C a) => C (T a)
C v => C (T a v)
(Ord i, C a) => C (T i a)
C v => C (T a v)
Produced by Haddock version 2.4.2