base-4.20.0.0: Core data structures and operations
Safe HaskellSafe
LanguageHaskell2010

GHC.Natural

Description

Compatibility module for pre ghc-bignum code.

Synopsis

Documentation

data Natural where Source #

Natural number

Invariant: numbers <= 0xffffffffffffffff use the NS constructor

Bundled Patterns

pattern NatS# :: Word# -> Natural 
pattern NatJ# :: BigNat -> Natural 

Instances

Instances details
PrintfArg Natural Source #

Since: base-4.8.0.0

Instance details

Defined in Text.Printf

Bits Natural Source #

Since: base-4.8.0

Instance details

Defined in GHC.Internal.Bits

Data Natural Source #

Since: base-4.8.0.0

Instance details

Defined in GHC.Internal.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 #

Enum Natural Source #

Since: base-4.8.0.0

Instance details

Defined in GHC.Internal.Enum

Ix Natural Source #

Since: base-4.8.0.0

Instance details

Defined in GHC.Internal.Ix

Num Natural Source #

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.Internal.Num

Read Natural Source #

Since: base-4.8.0.0

Instance details

Defined in GHC.Internal.Read

Integral Natural Source #

Since: base-4.8.0.0

Instance details

Defined in GHC.Internal.Real

Real Natural Source #

Since: base-4.8.0.0

Instance details

Defined in GHC.Internal.Real

Show Natural Source #

Since: base-4.8.0.0

Instance details

Defined in GHC.Internal.Show

Eq Natural Source # 
Instance details

Defined in GHC.Internal.Bignum.Natural

Ord Natural Source # 
Instance details

Defined in GHC.Internal.Bignum.Natural

KnownNat n => HasResolution (n :: Nat) Source #

For example, Fixed 1000 will give you a Fixed with a resolution of 1000.

Instance details

Defined in Data.Fixed

Methods

resolution :: p n -> Integer Source #

TestCoercion SNat Source #

Since: base-4.18.0.0

Instance details

Defined in GHC.Internal.TypeNats

Methods

testCoercion :: forall (a :: Nat) (b :: Nat). SNat a -> SNat b -> Maybe (Coercion a b) Source #

TestEquality SNat Source #

Since: base-4.18.0.0

Instance details

Defined in GHC.Internal.TypeNats

Methods

testEquality :: forall (a :: Nat) (b :: Nat). SNat a -> SNat b -> Maybe (a :~: b) Source #

Lift Natural Source # 
Instance details

Defined in GHC.Internal.TH.Lift

Methods

lift :: Quote m => Natural -> m Exp Source #

liftTyped :: forall (m :: Type -> Type). Quote m => Natural -> Code m Natural Source #

type Compare (a :: Natural) (b :: Natural) Source # 
Instance details

Defined in GHC.Internal.Data.Type.Ord

type Compare (a :: Natural) (b :: Natural) = CmpNat a b

data BigNat Source #

A lifted BigNat

Represented as an array of limbs (Word#) stored in little-endian order (Word# themselves use machine order).

Invariant (canonical representation): higher Word# is non-zero.

As a consequence, zero is represented with a WordArray# whose size is 0.

Constructors

BN# 

Fields

Instances

Instances details
Eq BigNat Source # 
Instance details

Defined in GHC.Internal.Bignum.BigNat

Ord BigNat Source # 
Instance details

Defined in GHC.Internal.Bignum.BigNat

mkNatural :: [Word] -> Natural Source #

Construct Natural value from list of Words.

isValidNatural :: Natural -> Bool Source #

Test whether all internal invariants are satisfied by Natural value

This operation is mostly useful for test-suites and/or code which constructs Integer values directly.

Since: base-4.8.0.0

Arithmetic

minusNaturalMaybe :: Natural -> Natural -> Maybe Natural Source #

Natural subtraction. Returns Nothings for non-positive results.

Since: base-4.8.0.0

gcdNatural :: Natural -> Natural -> Natural Source #

Compute greatest common divisor.

lcmNatural :: Natural -> Natural -> Natural Source #

Compute least common multiple.

Bits

Conversions

naturalToInteger :: Natural -> Integer Source #

Since: base-4.12.0.0

naturalToWordMaybe :: Natural -> Maybe Word Source #

Try downcasting Natural to Word value. Returns Nothing if value doesn't fit in Word.

Since: base-4.8.0.0

wordToNatural :: Word -> Natural Source #

Construct Natural from Word value.

Since: base-4.8.0.0

naturalFromInteger :: Integer -> Natural Source #

Since: base-4.10.0.0

Modular arithmetic

powModNatural :: Natural -> Natural -> Natural -> Natural Source #

"powModNatural b e m" computes base b raised to exponent e modulo m.

Since: base-4.8.0.0