module Algebra.ZeroTestable where
import qualified Prelude as P
import PreludeBase
import qualified Algebra.Additive as Additive
class C a where
isZero :: a -> Bool
defltIsZero :: (Eq a, Additive.C a) => a -> Bool
defltIsZero = (Additive.zero==)
instance C P.Integer where
isZero = defltIsZero
instance C P.Int where
isZero = defltIsZero
instance C P.Float where
isZero = defltIsZero
instance C P.Double where
isZero = defltIsZero
instance (C v0, C v1) => C (v0, v1) where
isZero (x0,x1) = isZero x0 && isZero x1
instance (C v0, C v1, C v2) => C (v0, v1, v2) where
isZero (x0,x1,x2) = isZero x0 && isZero x1 && isZero x2
instance (C v) => C [v] where
isZero = all isZero