HORIZON HASKELLDocslts/ghc-9.14.x3e2d5682026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 3e2d568 · 2026-10-11

Moduleghc-internal-9.1401.0Haskell2010

GHC.Internal.Bignum.Natural

  • 1 type
  • 81 values
datadata Natural
#

Natural number

Invariant: numbers <= 0xffffffffffffffff use the NS constructor

Constructors

Instances15Enum, Eq, Integral, Data, Num, Ord, …
  • Enum NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.Enum
  • Eq NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.Bignum.Natural
  • Integral NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.Real
  • Data NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.Data.Data
  • Num NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.Num

    Note that Natural's Num instance isn't a ring: no element but 0 has an additive inverse. It is a semiring though.

  • Ord NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.Bignum.Natural
  • Read NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.Read
  • Real NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.Real
  • Show NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.Show
  • Ix NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.Ix
  • Bits NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.Bits
  • Lift NaturalDefined in ghc-internal-9.1401.0 · GHC.Internal.TH.Lift
  • TestCoercion SNatDefined in ghc-internal-9.1401.0 · GHC.Internal.TypeNats
  • TestEquality SNatDefined in ghc-internal-9.1401.0 · GHC.Internal.TypeNats
  • type Compare a b = CmpNat a bDefined in ghc-internal-9.1401.0 · GHC.Internal.Data.Type.Ord

Useful constants

2 declarations

Predicates

3 declarations

Conversion with...

0 declarations

BigNat

Word

Limbs

Read a Natural in base-256 representation from a ByteArray#.

The size is given in bytes.

The endianness is selected with the Bool# parameter: most significant byte first (big-endian) if 1# or least significant byte first (little-endian) if 0#.

Null higher limbs are automatically trimed.

Floating point

Addr#

valuenaturalToAddr#
  1. :: Natural
  2. -> Addr#
  3. -> Bool#
  4. -> State# s
  5. -> (# State# s, Word# #)
#

Write a Natural to addr in base-256 representation and return the number of bytes written.

The endianness is selected with the Bool# parameter: write most significant byte first (big-endian) if 1# or least significant byte first (little-endian) if 0#.

valuenaturalToAddr :: Natural -> Addr# -> Bool# -> IO Word
#

Write a Natural to addr in base-256 representation and return the number of bytes written.

The endianness is selected with the Bool# parameter: write most significant byte first (big-endian) if 1# or least significant byte first (little-endian) if 0#.

valuenaturalFromAddr#
  1. :: Word#
  2. -> Addr#
  3. -> Bool#
  4. -> State# s
  5. -> (# State# s, Natural #)
#

Read a Natural in base-256 representation from an Addr#.

The size is given in bytes.

The endianness is selected with the Bool# parameter: most significant byte first (big-endian) if 1# or least significant byte first (little-endian) if 0#.

Null higher limbs are automatically trimed.

valuenaturalFromAddr :: Word# -> Addr# -> Bool# -> IO Natural
#

Read a Natural in base-256 representation from an Addr#.

The size is given in bytes.

The endianness is selected with the Bool# parameter: most significant byte first (big-endian) if 1# or least significant byte first (little-endian) if 0#.

Null higher limbs are automatically trimed.

Comparison

13 declarations

Bit operations

20 declarations

Arithmetic

21 declarations

Miscellaneous

1 declaration