basement-0.0.11: Foundation scrap box of array & string

Safe Haskell | None
Language | Haskell2010

Basement.Compat.Natural

Synopsis

- data Natural
- integerToNatural :: Integer -> Natural
- naturalToInteger :: Natural -> Integer

# Documentation

data Natural Source #

Type representing arbitrary-precision non-negative integers.

    >>> 2^100 :: Natural
    1267650600228229401496703205376

Operations whose result would be negative ``throw` (`Underflow` :: `ArithException`)`,

    >>> -1 :: Natural
    *** Exception: arithmetic underflow

Since: base-4.8.0.0

#### Instances

Instances details

Enum Natural | Since: base-4.8.0.0

Instance details

Defined in GHC.Enum

Methods

succ :: Natural -> Natural Source #

pred :: Natural -> Natural Source #

toEnum :: Int -> Natural Source #

fromEnum :: Natural -> Int Source #

enumFrom :: Natural -> [Natural] Source #

enumFromThen :: Natural -> Natural -> [Natural] Source #

enumFromTo :: Natural -> Natural -> [Natural] Source #

enumFromThenTo :: Natural -> Natural -> Natural -> [Natural] Source #

Eq Natural | Since: base-4.8.0.0
Instance details Defined in GHC.Natural Methods (==) :: Natural -> Natural -> Bool Source # (/=) :: Natural -> Natural -> Bool Source #
Integral Natural | Since: base-4.8.0.0
Instance details Defined in GHC.Real Methods quot :: Natural -> Natural -> Natural Source # rem :: Natural -> Natural -> Natural Source # div :: Natural -> Natural -> Natural Source # mod :: Natural -> Natural -> Natural Source # quotRem :: Natural -> Natural -> (Natural, Natural) Source # divMod :: Natural -> Natural -> (Natural, Natural) Source # toInteger :: Natural -> Integer Source #
Data Natural | Since: base-4.8.0.0

Instance details

Defined in Data.Data

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Natural -> c Natural Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Natural Source #

toConstr :: Natural -> Constr Source #

dataTypeOf :: Natural -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Natural) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Natural) Source #

gmapT :: (forall b. Data b => b -> b) -> Natural -> Natural Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Natural -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Natural -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Natural -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Natural -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Natural -> m Natural Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Natural -> m Natural Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Natural -> m Natural Source #

Num Natural | Note that `Natural`'s `Num` instance isn't a ring: no element but 0 has an additive inverse. It is a semiring though. Since: base-4.8.0.0
Instance details Defined in GHC.Num Methods (+) :: Natural -> Natural -> Natural Source # (-) :: Natural -> Natural -> Natural Source # (*) :: Natural -> Natural -> Natural Source # negate :: Natural -> Natural Source # abs :: Natural -> Natural Source # signum :: Natural -> Natural Source # fromInteger :: Integer -> Natural Source #
Ord Natural | Since: base-4.8.0.0
Instance details Defined in GHC.Natural Methods compare :: Natural -> Natural -> Ordering Source # (<) :: Natural -> Natural -> Bool Source # (<=) :: Natural -> Natural -> Bool Source # (>) :: Natural -> Natural -> Bool Source # (>=) :: Natural -> Natural -> Bool Source # max :: Natural -> Natural -> Natural Source # min :: Natural -> Natural -> Natural Source #
Read Natural | Since: base-4.8.0.0
Instance details Defined in GHC.Read Methods readsPrec :: Int -> ReadS Natural Source # readList :: ReadS [Natural] Source # readPrec :: ReadPrec Natural Source # readListPrec :: ReadPrec [Natural] Source #
Real Natural | Since: base-4.8.0.0
Instance details Defined in GHC.Real Methods toRational :: Natural -> Rational Source #
Show Natural | Since: base-4.8.0.0
Instance details Defined in GHC.Show Methods showsPrec :: Int -> Natural -> ShowS Source # show :: Natural -> String Source # showList :: [Natural] -> ShowS Source #
Ix Natural | Since: base-4.8.0.0
Instance details Defined in GHC.Arr Methods range :: (Natural, Natural) -> [Natural] Source # index :: (Natural, Natural) -> Natural -> Int Source # unsafeIndex :: (Natural, Natural) -> Natural -> Int Source # inRange :: (Natural, Natural) -> Natural -> Bool Source # rangeSize :: (Natural, Natural) -> Int Source # unsafeRangeSize :: (Natural, Natural) -> Int Source #
Bits Natural | Since: base-4.8.0

Instance details

Defined in Data.Bits

Methods

(.&.) :: Natural -> Natural -> Natural Source #

(.|.) :: Natural -> Natural -> Natural Source #

xor :: Natural -> Natural -> Natural Source #

complement :: Natural -> Natural Source #

shift :: Natural -> Int -> Natural Source #

rotate :: Natural -> Int -> Natural Source #

zeroBits :: Natural Source #

bit :: Int -> Natural Source #

setBit :: Natural -> Int -> Natural Source #

clearBit :: Natural -> Int -> Natural Source #

complementBit :: Natural -> Int -> Natural Source #

testBit :: Natural -> Int -> Bool Source #

bitSizeMaybe :: Natural -> Maybe Int Source #

bitSize :: Natural -> Int Source #

isSigned :: Natural -> Bool Source #

shiftL :: Natural -> Int -> Natural Source #

unsafeShiftL :: Natural -> Int -> Natural Source #

shiftR :: Natural -> Int -> Natural Source #

unsafeShiftR :: Natural -> Int -> Natural Source #

rotateL :: Natural -> Int -> Natural Source #

rotateR :: Natural -> Int -> Natural Source #

popCount :: Natural -> Int Source #

Integral Natural Source # |
Instance details Defined in Basement.Compat.NumLiteral Methods fromInteger :: Integer -> Natural Source #
IsNatural Natural Source # |
Instance details Defined in Basement.Numerical.Number Methods toNatural :: Natural -> Natural Source #
IsIntegral Natural Source # |
Instance details Defined in Basement.Numerical.Number Methods toInteger :: Natural -> Integer Source #
Subtractive Natural Source # |
Instance details Defined in Basement.Numerical.Subtractive Associated Types type Difference Natural Source # Methods (-) :: Natural -> Natural -> Difference Natural Source #
Additive Natural Source # |
Instance details Defined in Basement.Numerical.Additive Methods azero :: Natural Source # (+) :: Natural -> Natural -> Natural Source # scale :: IsNatural n => n -> Natural -> Natural Source #
IDivisible Natural Source # |
Instance details Defined in Basement.Numerical.Multiplicative Methods div :: Natural -> Natural -> Natural Source # mod :: Natural -> Natural -> Natural Source # divMod :: Natural -> Natural -> (Natural, Natural) Source #
Multiplicative Natural Source # |
Instance details Defined in Basement.Numerical.Multiplicative Methods midentity :: Natural Source # (*) :: Natural -> Natural -> Natural Source # (^) :: (IsNatural n, Enum n, IDivisible n) => Natural -> n -> Natural Source #
NormalForm Natural Source # |
Instance details Defined in Basement.NormalForm Methods toNormalForm :: Natural -> () Source #
IsNatural a => IntegralUpsize a Natural Source # |
Instance details Defined in Basement.IntegralConv Methods integralUpsize :: a -> Natural Source #
IntegralDownsize Integer Natural Source # |
Instance details Defined in Basement.IntegralConv Methods integralDownsize :: Integer -> Natural Source # integralDownsizeCheck :: Integer -> Maybe Natural Source #
IntegralDownsize Natural Word8 Source # |
Instance details Defined in Basement.IntegralConv Methods integralDownsize :: Natural -> Word8 Source # integralDownsizeCheck :: Natural -> Maybe Word8 Source #
IntegralDownsize Natural Word16 Source # |
Instance details Defined in Basement.IntegralConv Methods integralDownsize :: Natural -> Word16 Source # integralDownsizeCheck :: Natural -> Maybe Word16 Source #
IntegralDownsize Natural Word32 Source # |
Instance details Defined in Basement.IntegralConv Methods integralDownsize :: Natural -> Word32 Source # integralDownsizeCheck :: Natural -> Maybe Word32 Source #
IntegralDownsize Natural Word64 Source # |
Instance details Defined in Basement.IntegralConv Methods integralDownsize :: Natural -> Word64 Source # integralDownsizeCheck :: Natural -> Maybe Word64 Source #
IsNatural n => From n Natural Source # |
Instance details Defined in Basement.From Methods from :: n -> Natural Source #
type Difference Natural Source # |
Instance details Defined in Basement.Numerical.Subtractive type Difference Natural = Maybe Natural

integerToNatural :: Integer -> Natural Source #

naturalToInteger :: Natural -> Integer Source #