HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleghc-bignum-1.3Haskell2010

GHC.Num.WordArray

  • 4 types
  • 37 values
  • Packageghc-bignum-1.3
  • Exports41
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceWordArray.hs
typetype WordArray# = ByteArray#
#

Unlifted array of Word

valuewordsToBytes# :: Int# -> Int#
#

Convert limb count into byte count

valuebytesToWords# :: Int# -> Int#
#

Convert byte count into limb count

valuewithNewWordArray#
  1. :: Int#

    Size in Word

  2. -> (MutableWordArray# RealWorld -> State# RealWorld -> State# RealWorld)
  3. -> WordArray#
#

Create a new WordArray# of the given size (*in Word#*) and apply the action to it before returning it frozen

valuewithNewWordArrayTrimmed#
  1. :: Int#

    Size in Word

  2. -> (MutableWordArray# RealWorld -> State# RealWorld -> State# RealWorld)
  3. -> WordArray#
#

Create a new WordArray# of the given size (*in Word#*), apply the action to it, trim its most significant zeroes, then return it frozen

valuewithNewWordArrayTrimmedMaybe#
  1. :: Int#

    Size in Word

  2. -> (MutableWordArray# RealWorld -> State# RealWorld -> (# State# RealWorld, Bool# #))
  3. -> (# (# #) | WordArray# #)
#

Create a new WordArray# of the given size (*in Word#*), apply the action to it. If the action returns true#, trim its most significant zeroes, then return it frozen. Otherwise, return ().

valuewordArrayFromWord2# :: Word# -> Word# -> WordArray#
#

Create a WordArray# from two Word#

`wordArrayFromWord2# h l where h is the most significant word l is the least significant word

valuemwaArrayCopy#
  1. :: MutableByteArray# s
  2. -> Int#
  3. -> WordArray#
  4. -> Int#
  5. -> Int#
  6. -> State# s
  7. -> State# s
#

Copy Words from a WordArray

Don't do anything if the number of words to copy is <= 0

valuemwaShrink# :: MutableByteArray# s -> Int# -> State# s -> State# s
#

Shrink last words of a WordArray

valuemwaSetSize# :: MutableByteArray# s -> Int# -> State# s -> State# s
#

Set size

valuemwaInitCopyShrink#
  1. :: MutableByteArray# s
  2. -> WordArray#
  3. -> State# s
  4. -> State# s
#

Copy the WordArray into the MWA and shrink the size of MWA to the one of the WordArray

valuemwaTrimZeroes# :: MutableByteArray# s -> State# s -> State# s
#

Trim ending zeroes

valuemwaClzAt :: MutableWordArray# s -> Int# -> State# s -> (# State# s, Int# #)
#

Count leading zero Words starting at given position

valuewaClzAt :: WordArray# -> Int# -> Int#
#

Count leading zero Words starting at given position

valuemwaInitArrayPlusWord
  1. :: MutableWordArray# s
  2. -> WordArray#
  3. -> Word#
  4. -> State# s
  5. -> State# s
#

Compute MutableWordArray <- WordArray + Word

The MutableWordArray may not be initialized and will be erased anyway.

Input: Size(MutableWordArray) = Size(WordArray) + 1 Output: Size(MutableWordArray) = Size(WordArray) [+ 1]

valuemwaWriteOrShrink
  1. :: MutableWordArray# s
  2. -> Word#
  3. -> Int#
  4. -> State# s
  5. -> State# s
#

Write the most-significant Word: * if it is 0: shrink the array of 1 Word * otherwise: write it

valuemwaFill#
  1. :: MutableWordArray# s
  2. -> Word#
  3. -> Word#
  4. -> Word#
  5. -> State# s
  6. -> State# s
#

Fill some part of a MutableWordArray with the given Word#

valuemwaSubInplaceWord#
  1. :: MutableWordArray# d
  2. -> Int#
  3. -> Word#
  4. -> State# d
  5. -> (# State# d, Bool# #)
#

Sub Word# inplace (at the specified offset) in the mwa with carry propagation.

Return False# on underflow

valuemwaAddInplaceArray
  1. :: MutableWordArray# d
  2. -> Int#
  3. -> WordArray#
  4. -> State# d
  5. -> State# d
#

Add array inplace (a the specified offset) in the mwa with carry propagation.

Upper bound of the result mutable aray is not checked against overflow.

valuemwaReadOrZero
  1. :: MutableWordArray# s
  2. -> Int#
  3. -> State# s
  4. -> (# State# s, Word# #)
#

Read an indexed Word in the MutableWordArray. If the index is out-of-bound, return zero.