module Foundation.Numerical.Number
( IsIntegral(..)
, IsNatural(..)
) where
import Foundation.Internal.Base
import Foundation.Internal.Natural
import qualified Prelude
class (Enum a, Eq a, Ord a, Integral a) => IsIntegral a where
toInteger :: a -> Integer
class (Enum a, Eq a, Ord a, Integral a, IsIntegral a) => IsNatural a where
toNatural :: a -> Natural
instance IsIntegral Integer where
toInteger i = i
instance IsIntegral Int where
toInteger i = Prelude.toInteger i
instance IsIntegral Int8 where
toInteger i = Prelude.toInteger i
instance IsIntegral Int16 where
toInteger i = Prelude.toInteger i
instance IsIntegral Int32 where
toInteger i = Prelude.toInteger i
instance IsIntegral Int64 where
toInteger i = Prelude.toInteger i
instance IsIntegral Natural where
toInteger i = Prelude.toInteger i
instance IsIntegral Word where
toInteger i = Prelude.toInteger i
instance IsIntegral Word8 where
toInteger i = Prelude.toInteger i
instance IsIntegral Word16 where
toInteger i = Prelude.toInteger i
instance IsIntegral Word32 where
toInteger i = Prelude.toInteger i
instance IsIntegral Word64 where
toInteger i = Prelude.toInteger i
instance IsNatural Natural where
toNatural i = i
instance IsNatural Word where
toNatural i = Prelude.fromIntegral i
instance IsNatural Word8 where
toNatural i = Prelude.fromIntegral i
instance IsNatural Word16 where
toNatural i = Prelude.fromIntegral i
instance IsNatural Word32 where
toNatural i = Prelude.fromIntegral i
instance IsNatural Word64 where
toNatural i = Prelude.fromIntegral i