1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
module Numeric.Decidable.Zero
( DecidableZero(..)
) where
import Numeric.Algebra.Class
import Data.Int
import Data.Word
import Numeric.Natural.Internal
class Monoidal r => DecidableZero r where
isZero :: r -> Bool
instance DecidableZero Bool where isZero = not
instance DecidableZero Integer where isZero = (0==)
instance DecidableZero Int where isZero = (0==)
instance DecidableZero Int8 where isZero = (0==)
instance DecidableZero Int16 where isZero = (0==)
instance DecidableZero Int32 where isZero = (0==)
instance DecidableZero Int64 where isZero = (0==)
instance DecidableZero Natural where isZero = (0==)
instance DecidableZero Word where isZero = (0==)
instance DecidableZero Word8 where isZero = (0==)
instance DecidableZero Word16 where isZero = (0==)
instance DecidableZero Word32 where isZero = (0==)
instance DecidableZero Word64 where isZero = (0==)
instance DecidableZero () where isZero _ = True
instance (DecidableZero a, DecidableZero b) => DecidableZero (a, b) where
isZero (a,b) = isZero a && isZero b
instance (DecidableZero a, DecidableZero b, DecidableZero c) => DecidableZero (a, b, c) where
isZero (a,b,c) = isZero a && isZero b && isZero c
instance (DecidableZero a, DecidableZero b, DecidableZero c, DecidableZero d) => DecidableZero (a, b, c, d) where
isZero (a,b,c,d) = isZero a && isZero b && isZero c && isZero d
instance (DecidableZero a, DecidableZero b, DecidableZero c, DecidableZero d, DecidableZero e) => DecidableZero (a, b, c, d, e) where
isZero (a,b,c,d,e) = isZero a && isZero b && isZero c && isZero d && isZero e
|