Haskell Hierarchical Libraries (base package)Source codeContentsIndex
GHC.Prim
Contents
The word size story.
Char#
Int#
Word#
Narrowings
Int64#
Word64#
Integer#
Double#
Float#
Arrays
Byte Arrays
Addr#
Mutable variables
Exceptions
STM-accessible Mutable Variables
Synchronized Mutable Variables
Delay/wait operations
Concurrency primitives
Weak pointers
Stable pointers and names
Unsafe pointer equality
Parallelism
Tag to enum stuff
Bytecode operations
Coercion
Synopsis
gtChar# :: Char# -> Char# -> Bool
geChar# :: Char# -> Char# -> Bool
eqChar# :: Char# -> Char# -> Bool
neChar# :: Char# -> Char# -> Bool
ltChar# :: Char# -> Char# -> Bool
leChar# :: Char# -> Char# -> Bool
ord# :: Char# -> Int#
(+#) :: Int# -> Int# -> Int#
(-#) :: Int# -> Int# -> Int#
(*#) :: Int# -> Int# -> Int#
mulIntMayOflo# :: Int# -> Int# -> Int#
quotInt# :: Int# -> Int# -> Int#
remInt# :: Int# -> Int# -> Int#
gcdInt# :: Int# -> Int# -> Int#
negateInt# :: Int# -> Int#
addIntC# :: Int# -> Int# -> (#Int#, Int##)
subIntC# :: Int# -> Int# -> (#Int#, Int##)
(>#) :: Int# -> Int# -> Bool
(>=#) :: Int# -> Int# -> Bool
(==#) :: Int# -> Int# -> Bool
(/=#) :: Int# -> Int# -> Bool
(<#) :: Int# -> Int# -> Bool
(<=#) :: Int# -> Int# -> Bool
chr# :: Int# -> Char#
int2Word# :: Int# -> Word#
int2Float# :: Int# -> Float#
int2Double# :: Int# -> Double#
int2Integer# :: Int# -> (#Int#, ByteArr##)
uncheckedIShiftL# :: Int# -> Int# -> Int#
uncheckedIShiftRA# :: Int# -> Int# -> Int#
uncheckedIShiftRL# :: Int# -> Int# -> Int#
plusWord# :: Word# -> Word# -> Word#
minusWord# :: Word# -> Word# -> Word#
timesWord# :: Word# -> Word# -> Word#
quotWord# :: Word# -> Word# -> Word#
remWord# :: Word# -> Word# -> Word#
and# :: Word# -> Word# -> Word#
or# :: Word# -> Word# -> Word#
xor# :: Word# -> Word# -> Word#
not# :: Word# -> Word#
uncheckedShiftL# :: Word# -> Int# -> Word#
uncheckedShiftRL# :: Word# -> Int# -> Word#
word2Int# :: Word# -> Int#
word2Integer# :: Word# -> (#Int#, ByteArr##)
gtWord# :: Word# -> Word# -> Bool
geWord# :: Word# -> Word# -> Bool
eqWord# :: Word# -> Word# -> Bool
neWord# :: Word# -> Word# -> Bool
ltWord# :: Word# -> Word# -> Bool
leWord# :: Word# -> Word# -> Bool
narrow8Int# :: Int# -> Int#
narrow16Int# :: Int# -> Int#
narrow32Int# :: Int# -> Int#
narrow8Word# :: Word# -> Word#
narrow16Word# :: Word# -> Word#
narrow32Word# :: Word# -> Word#
int64ToInteger# :: Int64# -> (#Int#, ByteArr##)
word64ToInteger# :: Word64# -> (#Int#, ByteArr##)
plusInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr##)
minusInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr##)
timesInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr##)
gcdInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr##)
gcdIntegerInt# :: Int# -> ByteArr# -> Int# -> Int#
divExactInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr##)
quotInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr##)
remInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr##)
cmpInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> Int#
cmpIntegerInt# :: Int# -> ByteArr# -> Int# -> Int#
quotRemInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr#, Int#, ByteArr##)
divModInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr#, Int#, ByteArr##)
integer2Int# :: Int# -> ByteArr# -> Int#
integer2Word# :: Int# -> ByteArr# -> Word#
andInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr##)
orInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr##)
xorInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr##)
complementInteger# :: Int# -> ByteArr# -> (#Int#, ByteArr##)
(>##) :: Double# -> Double# -> Bool
(>=##) :: Double# -> Double# -> Bool
(==##) :: Double# -> Double# -> Bool
(/=##) :: Double# -> Double# -> Bool
(<##) :: Double# -> Double# -> Bool
(<=##) :: Double# -> Double# -> Bool
(+##) :: Double# -> Double# -> Double#
(-##) :: Double# -> Double# -> Double#
(*##) :: Double# -> Double# -> Double#
(/##) :: Double# -> Double# -> Double#
negateDouble# :: Double# -> Double#
double2Int# :: Double# -> Int#
double2Float# :: Double# -> Float#
expDouble# :: Double# -> Double#
logDouble# :: Double# -> Double#
sqrtDouble# :: Double# -> Double#
sinDouble# :: Double# -> Double#
cosDouble# :: Double# -> Double#
tanDouble# :: Double# -> Double#
asinDouble# :: Double# -> Double#
acosDouble# :: Double# -> Double#
atanDouble# :: Double# -> Double#
sinhDouble# :: Double# -> Double#
coshDouble# :: Double# -> Double#
tanhDouble# :: Double# -> Double#
(**##) :: Double# -> Double# -> Double#
decodeDouble# :: Double# -> (#Int#, Int#, ByteArr##)
gtFloat# :: Float# -> Float# -> Bool
geFloat# :: Float# -> Float# -> Bool
eqFloat# :: Float# -> Float# -> Bool
neFloat# :: Float# -> Float# -> Bool
ltFloat# :: Float# -> Float# -> Bool
leFloat# :: Float# -> Float# -> Bool
plusFloat# :: Float# -> Float# -> Float#
minusFloat# :: Float# -> Float# -> Float#
timesFloat# :: Float# -> Float# -> Float#
divideFloat# :: Float# -> Float# -> Float#
negateFloat# :: Float# -> Float#
float2Int# :: Float# -> Int#
expFloat# :: Float# -> Float#
logFloat# :: Float# -> Float#
sqrtFloat# :: Float# -> Float#
sinFloat# :: Float# -> Float#
cosFloat# :: Float# -> Float#
tanFloat# :: Float# -> Float#
asinFloat# :: Float# -> Float#
acosFloat# :: Float# -> Float#
atanFloat# :: Float# -> Float#
sinhFloat# :: Float# -> Float#
coshFloat# :: Float# -> Float#
tanhFloat# :: Float# -> Float#
powerFloat# :: Float# -> Float# -> Float#
float2Double# :: Float# -> Double#
decodeFloat# :: Float# -> (#Int#, Int#, ByteArr##)
newArray# :: Int# -> a -> State# s -> (#State# s, MutArr# s a#)
sameMutableArray# :: MutArr# s a -> MutArr# s a -> Bool
readArray# :: MutArr# s a -> Int# -> State# s -> (#State# s, a#)
writeArray# :: MutArr# s a -> Int# -> a -> State# s -> State# s
indexArray# :: Array# a -> Int# -> (#a#)
unsafeFreezeArray# :: MutArr# s a -> State# s -> (#State# s, Array# a#)
unsafeThawArray# :: Array# a -> State# s -> (#State# s, MutArr# s a#)
newByteArray# :: Int# -> State# s -> (#State# s, MutByteArr# s#)
newPinnedByteArray# :: Int# -> State# s -> (#State# s, MutByteArr# s#)
byteArrayContents# :: ByteArr# -> Addr#
sameMutableByteArray# :: MutByteArr# s -> MutByteArr# s -> Bool
unsafeFreezeByteArray# :: MutByteArr# s -> State# s -> (#State# s, ByteArr##)
sizeofByteArray# :: ByteArr# -> Int#
sizeofMutableByteArray# :: MutByteArr# s -> Int#
indexCharArray# :: ByteArr# -> Int# -> Char#
indexWideCharArray# :: ByteArr# -> Int# -> Char#
indexIntArray# :: ByteArr# -> Int# -> Int#
indexWordArray# :: ByteArr# -> Int# -> Word#
indexAddrArray# :: ByteArr# -> Int# -> Addr#
indexFloatArray# :: ByteArr# -> Int# -> Float#
indexDoubleArray# :: ByteArr# -> Int# -> Double#
indexStablePtrArray# :: ByteArr# -> Int# -> StablePtr# a
indexInt8Array# :: ByteArr# -> Int# -> Int#
indexInt16Array# :: ByteArr# -> Int# -> Int#
indexInt32Array# :: ByteArr# -> Int# -> Int#
indexInt64Array# :: ByteArr# -> Int# -> Int64#
indexWord8Array# :: ByteArr# -> Int# -> Word#
indexWord16Array# :: ByteArr# -> Int# -> Word#
indexWord32Array# :: ByteArr# -> Int# -> Word#
indexWord64Array# :: ByteArr# -> Int# -> Word64#
readCharArray# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Char##)
readWideCharArray# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Char##)
readIntArray# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Int##)
readWordArray# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Word##)
readAddrArray# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Addr##)
readFloatArray# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Float##)
readDoubleArray# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Double##)
readStablePtrArray# :: MutByteArr# s -> Int# -> State# s -> (#State# s, StablePtr# a#)
readInt8Array# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Int##)
readInt16Array# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Int##)
readInt32Array# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Int##)
readInt64Array# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Int64##)
readWord8Array# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Word##)
readWord16Array# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Word##)
readWord32Array# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Word##)
readWord64Array# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Word64##)
writeCharArray# :: MutByteArr# s -> Int# -> Char# -> State# s -> State# s
writeWideCharArray# :: MutByteArr# s -> Int# -> Char# -> State# s -> State# s
writeIntArray# :: MutByteArr# s -> Int# -> Int# -> State# s -> State# s
writeWordArray# :: MutByteArr# s -> Int# -> Word# -> State# s -> State# s
writeAddrArray# :: MutByteArr# s -> Int# -> Addr# -> State# s -> State# s
writeFloatArray# :: MutByteArr# s -> Int# -> Float# -> State# s -> State# s
writeDoubleArray# :: MutByteArr# s -> Int# -> Double# -> State# s -> State# s
writeStablePtrArray# :: MutByteArr# s -> Int# -> StablePtr# a -> State# s -> State# s
writeInt8Array# :: MutByteArr# s -> Int# -> Int# -> State# s -> State# s
writeInt16Array# :: MutByteArr# s -> Int# -> Int# -> State# s -> State# s
writeInt32Array# :: MutByteArr# s -> Int# -> Int# -> State# s -> State# s
writeInt64Array# :: MutByteArr# s -> Int# -> Int64# -> State# s -> State# s
writeWord8Array# :: MutByteArr# s -> Int# -> Word# -> State# s -> State# s
writeWord16Array# :: MutByteArr# s -> Int# -> Word# -> State# s -> State# s
writeWord32Array# :: MutByteArr# s -> Int# -> Word# -> State# s -> State# s
writeWord64Array# :: MutByteArr# s -> Int# -> Word64# -> State# s -> State# s
plusAddr# :: Addr# -> Int# -> Addr#
minusAddr# :: Addr# -> Addr# -> Int#
remAddr# :: Addr# -> Int# -> Int#
addr2Int# :: Addr# -> Int#
int2Addr# :: Int# -> Addr#
gtAddr# :: Addr# -> Addr# -> Bool
geAddr# :: Addr# -> Addr# -> Bool
eqAddr# :: Addr# -> Addr# -> Bool
neAddr# :: Addr# -> Addr# -> Bool
ltAddr# :: Addr# -> Addr# -> Bool
leAddr# :: Addr# -> Addr# -> Bool
indexCharOffAddr# :: Addr# -> Int# -> Char#
indexWideCharOffAddr# :: Addr# -> Int# -> Char#
indexIntOffAddr# :: Addr# -> Int# -> Int#
indexWordOffAddr# :: Addr# -> Int# -> Word#
indexAddrOffAddr# :: Addr# -> Int# -> Addr#
indexFloatOffAddr# :: Addr# -> Int# -> Float#
indexDoubleOffAddr# :: Addr# -> Int# -> Double#
indexStablePtrOffAddr# :: Addr# -> Int# -> StablePtr# a
indexInt8OffAddr# :: Addr# -> Int# -> Int#
indexInt16OffAddr# :: Addr# -> Int# -> Int#
indexInt32OffAddr# :: Addr# -> Int# -> Int#
indexInt64OffAddr# :: Addr# -> Int# -> Int64#
indexWord8OffAddr# :: Addr# -> Int# -> Word#
indexWord16OffAddr# :: Addr# -> Int# -> Word#
indexWord32OffAddr# :: Addr# -> Int# -> Word#
indexWord64OffAddr# :: Addr# -> Int# -> Word64#
readCharOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Char##)
readWideCharOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Char##)
readIntOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Int##)
readWordOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Word##)
readAddrOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Addr##)
readFloatOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Float##)
readDoubleOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Double##)
readStablePtrOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, StablePtr# a#)
readInt8OffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Int##)
readInt16OffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Int##)
readInt32OffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Int##)
readInt64OffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Int64##)
readWord8OffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Word##)
readWord16OffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Word##)
readWord32OffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Word##)
readWord64OffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Word64##)
writeCharOffAddr# :: Addr# -> Int# -> Char# -> State# s -> State# s
writeWideCharOffAddr# :: Addr# -> Int# -> Char# -> State# s -> State# s
writeIntOffAddr# :: Addr# -> Int# -> Int# -> State# s -> State# s
writeWordOffAddr# :: Addr# -> Int# -> Word# -> State# s -> State# s
writeAddrOffAddr# :: Addr# -> Int# -> Addr# -> State# s -> State# s
writeFloatOffAddr# :: Addr# -> Int# -> Float# -> State# s -> State# s
writeDoubleOffAddr# :: Addr# -> Int# -> Double# -> State# s -> State# s
writeStablePtrOffAddr# :: Addr# -> Int# -> StablePtr# a -> State# s -> State# s
writeInt8OffAddr# :: Addr# -> Int# -> Int# -> State# s -> State# s
writeInt16OffAddr# :: Addr# -> Int# -> Int# -> State# s -> State# s
writeInt32OffAddr# :: Addr# -> Int# -> Int# -> State# s -> State# s
writeInt64OffAddr# :: Addr# -> Int# -> Int64# -> State# s -> State# s
writeWord8OffAddr# :: Addr# -> Int# -> Word# -> State# s -> State# s
writeWord16OffAddr# :: Addr# -> Int# -> Word# -> State# s -> State# s
writeWord32OffAddr# :: Addr# -> Int# -> Word# -> State# s -> State# s
writeWord64OffAddr# :: Addr# -> Int# -> Word64# -> State# s -> State# s
newMutVar# :: a -> State# s -> (#State# s, MutVar# s a#)
readMutVar# :: MutVar# s a -> State# s -> (#State# s, a#)
writeMutVar# :: MutVar# s a -> a -> State# s -> State# s
sameMutVar# :: MutVar# s a -> MutVar# s a -> Bool
atomicModifyMutVar# :: MutVar# s a -> (a -> b) -> State# s -> (#State# s, c#)
catch# :: (State# RealWorld -> (#State# RealWorld, a#)) -> (b -> State# RealWorld -> (#State# RealWorld, a#)) -> State# RealWorld -> (#State# RealWorld, a#)
raise# :: a -> b
raiseIO# :: a -> State# RealWorld -> (#State# RealWorld, b#)
blockAsyncExceptions# :: (State# RealWorld -> (#State# RealWorld, a#)) -> State# RealWorld -> (#State# RealWorld, a#)
unblockAsyncExceptions# :: (State# RealWorld -> (#State# RealWorld, a#)) -> State# RealWorld -> (#State# RealWorld, a#)
atomically# :: (State# RealWorld -> (#State# RealWorld, a#)) -> State# RealWorld -> (#State# RealWorld, a#)
retry# :: State# RealWorld -> (#State# RealWorld, a#)
catchRetry# :: (State# RealWorld -> (#State# RealWorld, a#)) -> (State# RealWorld -> (#State# RealWorld, a#)) -> State# RealWorld -> (#State# RealWorld, a#)
catchSTM# :: (State# RealWorld -> (#State# RealWorld, a#)) -> (b -> State# RealWorld -> (#State# RealWorld, a#)) -> State# RealWorld -> (#State# RealWorld, a#)
newTVar# :: a -> State# s -> (#State# s, TVar# s a#)
readTVar# :: TVar# s a -> State# s -> (#State# s, a#)
writeTVar# :: TVar# s a -> a -> State# s -> State# s
sameTVar# :: TVar# s a -> TVar# s a -> Bool
newMVar# :: State# s -> (#State# s, MVar# s a#)
takeMVar# :: MVar# s a -> State# s -> (#State# s, a#)
tryTakeMVar# :: MVar# s a -> State# s -> (#State# s, Int#, a#)
putMVar# :: MVar# s a -> a -> State# s -> State# s
tryPutMVar# :: MVar# s a -> a -> State# s -> (#State# s, Int##)
sameMVar# :: MVar# s a -> MVar# s a -> Bool
isEmptyMVar# :: MVar# s a -> State# s -> (#State# s, Int##)
delay# :: Int# -> State# s -> State# s
waitRead# :: Int# -> State# s -> State# s
waitWrite# :: Int# -> State# s -> State# s
fork# :: a -> State# RealWorld -> (#State# RealWorld, ThreadId##)
forkOn# :: Int# -> a -> State# RealWorld -> (#State# RealWorld, ThreadId##)
killThread# :: ThreadId# -> a -> State# RealWorld -> State# RealWorld
yield# :: State# RealWorld -> State# RealWorld
myThreadId# :: State# RealWorld -> (#State# RealWorld, ThreadId##)
labelThread# :: ThreadId# -> Addr# -> State# RealWorld -> State# RealWorld
isCurrentThreadBound# :: State# RealWorld -> (#State# RealWorld, Int##)
mkWeak# :: o -> b -> c -> State# RealWorld -> (#State# RealWorld, Weak# b#)
deRefWeak# :: Weak# a -> State# RealWorld -> (#State# RealWorld, Int#, a#)
finalizeWeak# :: Weak# a -> State# RealWorld -> (#State# RealWorld, Int#, State# RealWorld -> (#State# RealWorld, ()#)#)
touch# :: o -> State# RealWorld -> State# RealWorld
makeStablePtr# :: a -> State# RealWorld -> (#State# RealWorld, StablePtr# a#)
deRefStablePtr# :: StablePtr# a -> State# RealWorld -> (#State# RealWorld, a#)
eqStablePtr# :: StablePtr# a -> StablePtr# a -> Int#
makeStableName# :: a -> State# RealWorld -> (#State# RealWorld, StableName# a#)
eqStableName# :: StableName# a -> StableName# a -> Int#
stableNameToInt# :: StableName# a -> Int#
reallyUnsafePtrEquality# :: a -> a -> Int#
par# :: a -> Int#
parGlobal# :: a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
parLocal# :: a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
parAt# :: b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
parAtAbs# :: a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
parAtRel# :: a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
parAtForNow# :: b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
dataToTag# :: a -> Int#
tagToEnum# :: Int# -> a
addrToHValue# :: Addr# -> (#a#)
mkApUpd0# :: BCO# -> (#a#)
newBCO# :: ByteArr# -> ByteArr# -> Array# a -> ByteArr# -> Int# -> ByteArr# -> State# s -> (#State# s, BCO##)
The word size story.

Haskell98 specifies that signed integers (type Int) must contain at least 30 bits. GHC always implements Int using the primitive type Int#, whose size equals the MachDeps.h constant WORD_SIZE_IN_BITS. This is normally set based on the config.h parameter SIZEOF_HSWORD, i.e., 32 bits on 32-bit machines, 64 bits on 64-bit machines. However, it can also be explicitly set to a smaller number, e.g., 31 bits, to allow the possibility of using tag bits. Currently GHC itself has only 32-bit and 64-bit variants, but 30 or 31-bit code can be exported as an external core file for use in other back ends.

GHC also implements a primitive unsigned integer type Word# which always has the same number of bits as Int#.

In addition, GHC supports families of explicit-sized integers and words at 8, 16, 32, and 64 bits, with the usual arithmetic operations, comparisons, and a range of conversions. The 8-bit and 16-bit sizes are always represented as Int# and Word#, and the operations implemented in terms of the the primops on these types, with suitable range restrictions on the results (using the narrow$n$Int# and narrow$n$Word# families of primops. The 32-bit sizes are represented using Int# and Word# when WORD_SIZE_IN_BITS $geq$ 32; otherwise, these are represented using distinct primitive types Int32# and Word32#. These (when needed) have a complete set of corresponding operations; however, nearly all of these are implemented as external C functions rather than as primops. Exactly the same story applies to the 64-bit sizes. All of these details are hidden under the PrelInt and PrelWord modules, which use #if-defs to invoke the appropriate types and operators.

Word size also matters for the families of primops for indexing/reading/writing fixed-size quantities at offsets from an array base, address, or foreign pointer. Here, a slightly different approach is taken. The names of these primops are fixed, but their {it types} vary according to the value of WORD_SIZE_IN_BITS. For example, if word size is at least 32 bits then an operator like indexInt32Array# has type ByteArr# -> Int# -> Int#; otherwise it has type ByteArr# -> Int# -> Int32#. This approach confines the necessary #if-defs to this file; no conditional compilation is needed in the files that expose these primops.

Finally, there are strongly deprecated primops for coercing between Addr#, the primitive type of machine addresses, and Int#. These are pretty bogus anyway, but will work on existing 32-bit and 64-bit GHC targets; they are completely bogus when tag bits are used in Int#, so are not available in this case.

Char#
Operations on 31-bit characters.
gtChar# :: Char# -> Char# -> Bool
geChar# :: Char# -> Char# -> Bool
eqChar# :: Char# -> Char# -> Bool
neChar# :: Char# -> Char# -> Bool
ltChar# :: Char# -> Char# -> Bool
leChar# :: Char# -> Char# -> Bool
ord# :: Char# -> Int#
Int#
Operations on native-size integers (30+ bits).
(+#) :: Int# -> Int# -> Int#
(-#) :: Int# -> Int# -> Int#
(*#) :: Int# -> Int# -> Int#
Low word of signed integer multiply.
mulIntMayOflo# :: Int# -> Int# -> Int#

Return non-zero if there is any possibility that the upper word of a signed integer multiply might contain useful information. Return zero only if you are completely sure that no overflow can occur. On a 32-bit platform, the recommmended implementation is to do a 32 x 32 -> 64 signed multiply, and subtract result[63:32] from (result[31] >>signed 31). If this is zero, meaning that the upper word is merely a sign extension of the lower one, no overflow can occur.

On a 64-bit platform it is not always possible to acquire the top 64 bits of the result. Therefore, a recommended implementation is to take the absolute value of both operands, and return 0 iff bits[63:31] of them are zero, since that means that their magnitudes fit within 31 bits, so the magnitude of the product must fit into 62 bits.

If in doubt, return non-zero, but do make an effort to create the correct answer for small args, since otherwise the performance of (*) :: Integer -> Integer -> Integer will be poor.

quotInt# :: Int# -> Int# -> Int#
Rounds towards zero.
remInt# :: Int# -> Int# -> Int#
Satisfies (quotInt# x y) *# y +# (remInt# x y) == x.
gcdInt# :: Int# -> Int# -> Int#
negateInt# :: Int# -> Int#
addIntC# :: Int# -> Int# -> (#Int#, Int##)
Add with carry. First member of result is (wrapped) sum; second member is 0 iff no overflow occured.
subIntC# :: Int# -> Int# -> (#Int#, Int##)
Subtract with carry. First member of result is (wrapped) difference; second member is 0 iff no overflow occured.
(>#) :: Int# -> Int# -> Bool
(>=#) :: Int# -> Int# -> Bool
(==#) :: Int# -> Int# -> Bool
(/=#) :: Int# -> Int# -> Bool
(<#) :: Int# -> Int# -> Bool
(<=#) :: Int# -> Int# -> Bool
chr# :: Int# -> Char#
int2Word# :: Int# -> Word#
int2Float# :: Int# -> Float#
int2Double# :: Int# -> Double#
int2Integer# :: Int# -> (#Int#, ByteArr##)
uncheckedIShiftL# :: Int# -> Int# -> Int#
Shift left. Result undefined if shift amount is not in the range 0 to word size - 1 inclusive.
uncheckedIShiftRA# :: Int# -> Int# -> Int#
Shift right arithmetic. Result undefined if shift amount is not in the range 0 to word size - 1 inclusive.
uncheckedIShiftRL# :: Int# -> Int# -> Int#
Shift right logical. Result undefined if shift amount is not in the range 0 to word size - 1 inclusive.
Word#
Operations on native-sized unsigned words (30+ bits).
plusWord# :: Word# -> Word# -> Word#
minusWord# :: Word# -> Word# -> Word#
timesWord# :: Word# -> Word# -> Word#
quotWord# :: Word# -> Word# -> Word#
remWord# :: Word# -> Word# -> Word#
and# :: Word# -> Word# -> Word#
or# :: Word# -> Word# -> Word#
xor# :: Word# -> Word# -> Word#
not# :: Word# -> Word#
uncheckedShiftL# :: Word# -> Int# -> Word#
Shift left logical. Result undefined if shift amount is not in the range 0 to word size - 1 inclusive.
uncheckedShiftRL# :: Word# -> Int# -> Word#
Shift right logical. Result undefined if shift amount is not in the range 0 to word size - 1 inclusive.
word2Int# :: Word# -> Int#
word2Integer# :: Word# -> (#Int#, ByteArr##)
gtWord# :: Word# -> Word# -> Bool
geWord# :: Word# -> Word# -> Bool
eqWord# :: Word# -> Word# -> Bool
neWord# :: Word# -> Word# -> Bool
ltWord# :: Word# -> Word# -> Bool
leWord# :: Word# -> Word# -> Bool
Narrowings
Explicit narrowing of native-sized ints or words.
narrow8Int# :: Int# -> Int#
narrow16Int# :: Int# -> Int#
narrow32Int# :: Int# -> Int#
narrow8Word# :: Word# -> Word#
narrow16Word# :: Word# -> Word#
narrow32Word# :: Word# -> Word#
Int64#
Operations on 64-bit unsigned words. This type is only used if plain Int# has less than 64 bits. In any case, the operations are not primops; they are implemented (if needed) as ccalls instead.
int64ToInteger# :: Int64# -> (#Int#, ByteArr##)
Word64#
Operations on 64-bit unsigned words. This type is only used if plain Word# has less than 64 bits. In any case, the operations are not primops; they are implemented (if needed) as ccalls instead.
word64ToInteger# :: Word64# -> (#Int#, ByteArr##)
Integer#

Operations on arbitrary-precision integers. These operations are implemented via the GMP package. An integer is represented as a pair consisting of an Int# representing the number of 'limbs' in use and the sign, and a ByteArr# containing the 'limbs' themselves. Such pairs are returned as unboxed pairs, but must be passed as separate components.

For .NET these operations are implemented by foreign imports, so the primops are omitted.

plusInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr##)
minusInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr##)
timesInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr##)
gcdInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr##)
Greatest common divisor.
gcdIntegerInt# :: Int# -> ByteArr# -> Int# -> Int#
Greatest common divisor, where second argument is an ordinary Int#.
divExactInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr##)
Divisor is guaranteed to be a factor of dividend.
quotInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr##)
Rounds towards zero.
remInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr##)
Satisfies plusInteger# (timesInteger# (quotInteger# x y) y) (remInteger# x y) == x.
cmpInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> Int#
Returns -1,0,1 according as first argument is less than, equal to, or greater than second argument.
cmpIntegerInt# :: Int# -> ByteArr# -> Int# -> Int#
Returns -1,0,1 according as first argument is less than, equal to, or greater than second argument, which is an ordinary Int#.
quotRemInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr#, Int#, ByteArr##)
Compute quot and rem simulaneously.
divModInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr#, Int#, ByteArr##)
Compute div and mod simultaneously, where div rounds towards negative infinity and(q,r) = divModInteger#(x,y) implies plusInteger# (timesInteger# q y) r = x.
integer2Int# :: Int# -> ByteArr# -> Int#
integer2Word# :: Int# -> ByteArr# -> Word#
andInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr##)
orInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr##)
xorInteger# :: Int# -> ByteArr# -> Int# -> ByteArr# -> (#Int#, ByteArr##)
complementInteger# :: Int# -> ByteArr# -> (#Int#, ByteArr##)
Double#
Operations on double-precision (64 bit) floating-point numbers.
(>##) :: Double# -> Double# -> Bool
(>=##) :: Double# -> Double# -> Bool
(==##) :: Double# -> Double# -> Bool
(/=##) :: Double# -> Double# -> Bool
(<##) :: Double# -> Double# -> Bool
(<=##) :: Double# -> Double# -> Bool
(+##) :: Double# -> Double# -> Double#
(-##) :: Double# -> Double# -> Double#
(*##) :: Double# -> Double# -> Double#
(/##) :: Double# -> Double# -> Double#
negateDouble# :: Double# -> Double#
double2Int# :: Double# -> Int#
double2Float# :: Double# -> Float#
expDouble# :: Double# -> Double#
logDouble# :: Double# -> Double#
sqrtDouble# :: Double# -> Double#
sinDouble# :: Double# -> Double#
cosDouble# :: Double# -> Double#
tanDouble# :: Double# -> Double#
asinDouble# :: Double# -> Double#
acosDouble# :: Double# -> Double#
atanDouble# :: Double# -> Double#
sinhDouble# :: Double# -> Double#
coshDouble# :: Double# -> Double#
tanhDouble# :: Double# -> Double#
(**##) :: Double# -> Double# -> Double#
Exponentiation.
decodeDouble# :: Double# -> (#Int#, Int#, ByteArr##)
Convert to arbitrary-precision integer. First Int# in result is the exponent; second Int# and ByteArr# represent an Integer# holding the mantissa.
Float#
Operations on single-precision (32-bit) floating-point numbers.
gtFloat# :: Float# -> Float# -> Bool
geFloat# :: Float# -> Float# -> Bool
eqFloat# :: Float# -> Float# -> Bool
neFloat# :: Float# -> Float# -> Bool
ltFloat# :: Float# -> Float# -> Bool
leFloat# :: Float# -> Float# -> Bool
plusFloat# :: Float# -> Float# -> Float#
minusFloat# :: Float# -> Float# -> Float#
timesFloat# :: Float# -> Float# -> Float#
divideFloat# :: Float# -> Float# -> Float#
negateFloat# :: Float# -> Float#
float2Int# :: Float# -> Int#
expFloat# :: Float# -> Float#
logFloat# :: Float# -> Float#
sqrtFloat# :: Float# -> Float#
sinFloat# :: Float# -> Float#
cosFloat# :: Float# -> Float#
tanFloat# :: Float# -> Float#
asinFloat# :: Float# -> Float#
acosFloat# :: Float# -> Float#
atanFloat# :: Float# -> Float#
sinhFloat# :: Float# -> Float#
coshFloat# :: Float# -> Float#
tanhFloat# :: Float# -> Float#
powerFloat# :: Float# -> Float# -> Float#
float2Double# :: Float# -> Double#
decodeFloat# :: Float# -> (#Int#, Int#, ByteArr##)
Convert to arbitrary-precision integer. First Int# in result is the exponent; second Int# and ByteArr# represent an Integer# holding the mantissa.
Arrays
Operations on Array#.
newArray# :: Int# -> a -> State# s -> (#State# s, MutArr# s a#)
Create a new mutable array of specified size (in bytes), in the specified state thread, with each element containing the specified initial value.
sameMutableArray# :: MutArr# s a -> MutArr# s a -> Bool
readArray# :: MutArr# s a -> Int# -> State# s -> (#State# s, a#)
Read from specified index of mutable array. Result is not yet evaluated.
writeArray# :: MutArr# s a -> Int# -> a -> State# s -> State# s
Write to specified index of mutable array.
indexArray# :: Array# a -> Int# -> (#a#)
Read from specified index of immutable array. Result is packaged into an unboxed singleton; the result itself is not yet evaluated.
unsafeFreezeArray# :: MutArr# s a -> State# s -> (#State# s, Array# a#)
Make a mutable array immutable, without copying.
unsafeThawArray# :: Array# a -> State# s -> (#State# s, MutArr# s a#)
Make an immutable array mutable, without copying.
Byte Arrays
Operations on ByteArray#. A ByteArray# is a just a region of raw memory in the garbage-collected heap, which is not scanned for pointers. It carries its own size (in bytes). There are three sets of operations for accessing byte array contents: index for reading from immutable byte arrays, and read/write for mutable byte arrays. Each set contains operations for a range of useful primitive data types. Each operation takes an offset measured in terms of the size fo the primitive type being read or written.
newByteArray# :: Int# -> State# s -> (#State# s, MutByteArr# s#)
Create a new mutable byte array of specified size (in bytes), in the specified state thread.
newPinnedByteArray# :: Int# -> State# s -> (#State# s, MutByteArr# s#)
Create a mutable byte array that the GC guarantees not to move.
byteArrayContents# :: ByteArr# -> Addr#
Intended for use with pinned arrays; otherwise very unsafe!
sameMutableByteArray# :: MutByteArr# s -> MutByteArr# s -> Bool
unsafeFreezeByteArray# :: MutByteArr# s -> State# s -> (#State# s, ByteArr##)
Make a mutable byte array immutable, without copying.
sizeofByteArray# :: ByteArr# -> Int#
sizeofMutableByteArray# :: MutByteArr# s -> Int#
indexCharArray# :: ByteArr# -> Int# -> Char#
Read 8-bit character; offset in bytes.
indexWideCharArray# :: ByteArr# -> Int# -> Char#
Read 31-bit character; offset in 4-byte words.
indexIntArray# :: ByteArr# -> Int# -> Int#
indexWordArray# :: ByteArr# -> Int# -> Word#
indexAddrArray# :: ByteArr# -> Int# -> Addr#
indexFloatArray# :: ByteArr# -> Int# -> Float#
indexDoubleArray# :: ByteArr# -> Int# -> Double#
indexStablePtrArray# :: ByteArr# -> Int# -> StablePtr# a
indexInt8Array# :: ByteArr# -> Int# -> Int#
indexInt16Array# :: ByteArr# -> Int# -> Int#
indexInt32Array# :: ByteArr# -> Int# -> Int#
indexInt64Array# :: ByteArr# -> Int# -> Int64#
indexWord8Array# :: ByteArr# -> Int# -> Word#
indexWord16Array# :: ByteArr# -> Int# -> Word#
indexWord32Array# :: ByteArr# -> Int# -> Word#
indexWord64Array# :: ByteArr# -> Int# -> Word64#
readCharArray# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Char##)
Read 8-bit character; offset in bytes.
readWideCharArray# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Char##)
Read 31-bit character; offset in 4-byte words.
readIntArray# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Int##)
readWordArray# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Word##)
readAddrArray# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Addr##)
readFloatArray# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Float##)
readDoubleArray# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Double##)
readStablePtrArray# :: MutByteArr# s -> Int# -> State# s -> (#State# s, StablePtr# a#)
readInt8Array# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Int##)
readInt16Array# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Int##)
readInt32Array# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Int##)
readInt64Array# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Int64##)
readWord8Array# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Word##)
readWord16Array# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Word##)
readWord32Array# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Word##)
readWord64Array# :: MutByteArr# s -> Int# -> State# s -> (#State# s, Word64##)
writeCharArray# :: MutByteArr# s -> Int# -> Char# -> State# s -> State# s
Write 8-bit character; offset in bytes.
writeWideCharArray# :: MutByteArr# s -> Int# -> Char# -> State# s -> State# s
Write 31-bit character; offset in 4-byte words.
writeIntArray# :: MutByteArr# s -> Int# -> Int# -> State# s -> State# s
writeWordArray# :: MutByteArr# s -> Int# -> Word# -> State# s -> State# s
writeAddrArray# :: MutByteArr# s -> Int# -> Addr# -> State# s -> State# s
writeFloatArray# :: MutByteArr# s -> Int# -> Float# -> State# s -> State# s
writeDoubleArray# :: MutByteArr# s -> Int# -> Double# -> State# s -> State# s
writeStablePtrArray# :: MutByteArr# s -> Int# -> StablePtr# a -> State# s -> State# s
writeInt8Array# :: MutByteArr# s -> Int# -> Int# -> State# s -> State# s
writeInt16Array# :: MutByteArr# s -> Int# -> Int# -> State# s -> State# s
writeInt32Array# :: MutByteArr# s -> Int# -> Int# -> State# s -> State# s
writeInt64Array# :: MutByteArr# s -> Int# -> Int64# -> State# s -> State# s
writeWord8Array# :: MutByteArr# s -> Int# -> Word# -> State# s -> State# s
writeWord16Array# :: MutByteArr# s -> Int# -> Word# -> State# s -> State# s
writeWord32Array# :: MutByteArr# s -> Int# -> Word# -> State# s -> State# s
writeWord64Array# :: MutByteArr# s -> Int# -> Word64# -> State# s -> State# s
Addr#

Addr# is an arbitrary machine address assumed to point outside the garbage-collected heap.

NB: nullAddr#::Addr# is not a primop, but is defined in MkId.lhs. It is the null address.

plusAddr# :: Addr# -> Int# -> Addr#
minusAddr# :: Addr# -> Addr# -> Int#
Result is meaningless if two Addr#s are so far apart that their difference doesn't fit in an Int#.
remAddr# :: Addr# -> Int# -> Int#
Return the remainder when the Addr# arg, treated like an Int#, is divided by the Int# arg.
addr2Int# :: Addr# -> Int#
Coerce directly from address to int. Strongly deprecated.
int2Addr# :: Int# -> Addr#
Coerce directly from int to address. Strongly deprecated.
gtAddr# :: Addr# -> Addr# -> Bool
geAddr# :: Addr# -> Addr# -> Bool
eqAddr# :: Addr# -> Addr# -> Bool
neAddr# :: Addr# -> Addr# -> Bool
ltAddr# :: Addr# -> Addr# -> Bool
leAddr# :: Addr# -> Addr# -> Bool
indexCharOffAddr# :: Addr# -> Int# -> Char#
Reads 8-bit character; offset in bytes.
indexWideCharOffAddr# :: Addr# -> Int# -> Char#
Reads 31-bit character; offset in 4-byte words.
indexIntOffAddr# :: Addr# -> Int# -> Int#
indexWordOffAddr# :: Addr# -> Int# -> Word#
indexAddrOffAddr# :: Addr# -> Int# -> Addr#
indexFloatOffAddr# :: Addr# -> Int# -> Float#
indexDoubleOffAddr# :: Addr# -> Int# -> Double#
indexStablePtrOffAddr# :: Addr# -> Int# -> StablePtr# a
indexInt8OffAddr# :: Addr# -> Int# -> Int#
indexInt16OffAddr# :: Addr# -> Int# -> Int#
indexInt32OffAddr# :: Addr# -> Int# -> Int#
indexInt64OffAddr# :: Addr# -> Int# -> Int64#
indexWord8OffAddr# :: Addr# -> Int# -> Word#
indexWord16OffAddr# :: Addr# -> Int# -> Word#
indexWord32OffAddr# :: Addr# -> Int# -> Word#
indexWord64OffAddr# :: Addr# -> Int# -> Word64#
readCharOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Char##)
Reads 8-bit character; offset in bytes.
readWideCharOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Char##)
Reads 31-bit character; offset in 4-byte words.
readIntOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Int##)
readWordOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Word##)
readAddrOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Addr##)
readFloatOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Float##)
readDoubleOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Double##)
readStablePtrOffAddr# :: Addr# -> Int# -> State# s -> (#State# s, StablePtr# a#)
readInt8OffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Int##)
readInt16OffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Int##)
readInt32OffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Int##)
readInt64OffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Int64##)
readWord8OffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Word##)
readWord16OffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Word##)
readWord32OffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Word##)
readWord64OffAddr# :: Addr# -> Int# -> State# s -> (#State# s, Word64##)
writeCharOffAddr# :: Addr# -> Int# -> Char# -> State# s -> State# s
writeWideCharOffAddr# :: Addr# -> Int# -> Char# -> State# s -> State# s
writeIntOffAddr# :: Addr# -> Int# -> Int# -> State# s -> State# s
writeWordOffAddr# :: Addr# -> Int# -> Word# -> State# s -> State# s
writeAddrOffAddr# :: Addr# -> Int# -> Addr# -> State# s -> State# s
writeFloatOffAddr# :: Addr# -> Int# -> Float# -> State# s -> State# s
writeDoubleOffAddr# :: Addr# -> Int# -> Double# -> State# s -> State# s
writeStablePtrOffAddr# :: Addr# -> Int# -> StablePtr# a -> State# s -> State# s
writeInt8OffAddr# :: Addr# -> Int# -> Int# -> State# s -> State# s
writeInt16OffAddr# :: Addr# -> Int# -> Int# -> State# s -> State# s
writeInt32OffAddr# :: Addr# -> Int# -> Int# -> State# s -> State# s
writeInt64OffAddr# :: Addr# -> Int# -> Int64# -> State# s -> State# s
writeWord8OffAddr# :: Addr# -> Int# -> Word# -> State# s -> State# s
writeWord16OffAddr# :: Addr# -> Int# -> Word# -> State# s -> State# s
writeWord32OffAddr# :: Addr# -> Int# -> Word# -> State# s -> State# s
writeWord64OffAddr# :: Addr# -> Int# -> Word64# -> State# s -> State# s
Mutable variables
Operations on MutVar#s, which behave like single-element mutable arrays.
newMutVar# :: a -> State# s -> (#State# s, MutVar# s a#)
Create MutVar# with specified initial value in specified state thread.
readMutVar# :: MutVar# s a -> State# s -> (#State# s, a#)
Read contents of MutVar#. Result is not yet evaluated.
writeMutVar# :: MutVar# s a -> a -> State# s -> State# s
Write contents of MutVar#.
sameMutVar# :: MutVar# s a -> MutVar# s a -> Bool
atomicModifyMutVar# :: MutVar# s a -> (a -> b) -> State# s -> (#State# s, c#)
Exceptions
catch# :: (State# RealWorld -> (#State# RealWorld, a#)) -> (b -> State# RealWorld -> (#State# RealWorld, a#)) -> State# RealWorld -> (#State# RealWorld, a#)
raise# :: a -> b
raiseIO# :: a -> State# RealWorld -> (#State# RealWorld, b#)
blockAsyncExceptions# :: (State# RealWorld -> (#State# RealWorld, a#)) -> State# RealWorld -> (#State# RealWorld, a#)
unblockAsyncExceptions# :: (State# RealWorld -> (#State# RealWorld, a#)) -> State# RealWorld -> (#State# RealWorld, a#)
STM-accessible Mutable Variables
atomically# :: (State# RealWorld -> (#State# RealWorld, a#)) -> State# RealWorld -> (#State# RealWorld, a#)
retry# :: State# RealWorld -> (#State# RealWorld, a#)
catchRetry# :: (State# RealWorld -> (#State# RealWorld, a#)) -> (State# RealWorld -> (#State# RealWorld, a#)) -> State# RealWorld -> (#State# RealWorld, a#)
catchSTM# :: (State# RealWorld -> (#State# RealWorld, a#)) -> (b -> State# RealWorld -> (#State# RealWorld, a#)) -> State# RealWorld -> (#State# RealWorld, a#)
newTVar# :: a -> State# s -> (#State# s, TVar# s a#)
Create a new Tar# holding a specified initial value.
readTVar# :: TVar# s a -> State# s -> (#State# s, a#)
Read contents of TVar#. Result is not yet evaluated.
writeTVar# :: TVar# s a -> a -> State# s -> State# s
Write contents of TVar#.
sameTVar# :: TVar# s a -> TVar# s a -> Bool
Synchronized Mutable Variables
Operations on MVar#s, which are shared mutable variables ({it not} the same as MutVar#s!). (Note: in a non-concurrent implementation, (MVar# a) can be represented by (MutVar# (Maybe a)).)
newMVar# :: State# s -> (#State# s, MVar# s a#)
Create new mvar; initially empty.
takeMVar# :: MVar# s a -> State# s -> (#State# s, a#)
If mvar is empty, block until it becomes full. Then remove and return its contents, and set it empty.
tryTakeMVar# :: MVar# s a -> State# s -> (#State# s, Int#, a#)
If mvar is empty, immediately return with integer 0 and value undefined. Otherwise, return with integer 1 and contents of mvar, and set mvar empty.
putMVar# :: MVar# s a -> a -> State# s -> State# s
If mvar is full, block until it becomes empty. Then store value arg as its new contents.
tryPutMVar# :: MVar# s a -> a -> State# s -> (#State# s, Int##)
If mvar is full, immediately return with integer 0. Otherwise, store value arg as mvar's new contents, and return with integer 1.
sameMVar# :: MVar# s a -> MVar# s a -> Bool
isEmptyMVar# :: MVar# s a -> State# s -> (#State# s, Int##)
Return 1 if mvar is empty; 0 otherwise.
Delay/wait operations
delay# :: Int# -> State# s -> State# s
Sleep specified number of microseconds.
waitRead# :: Int# -> State# s -> State# s
Block until input is available on specified file descriptor.
waitWrite# :: Int# -> State# s -> State# s
Block until output is possible on specified file descriptor.
Concurrency primitives
(In a non-concurrent implementation, ThreadId# can be as singleton type, whose (unique) value is returned by myThreadId#. The other operations can be omitted.)
fork# :: a -> State# RealWorld -> (#State# RealWorld, ThreadId##)
forkOn# :: Int# -> a -> State# RealWorld -> (#State# RealWorld, ThreadId##)
killThread# :: ThreadId# -> a -> State# RealWorld -> State# RealWorld
yield# :: State# RealWorld -> State# RealWorld
myThreadId# :: State# RealWorld -> (#State# RealWorld, ThreadId##)
labelThread# :: ThreadId# -> Addr# -> State# RealWorld -> State# RealWorld
isCurrentThreadBound# :: State# RealWorld -> (#State# RealWorld, Int##)
Weak pointers
mkWeak# :: o -> b -> c -> State# RealWorld -> (#State# RealWorld, Weak# b#)
deRefWeak# :: Weak# a -> State# RealWorld -> (#State# RealWorld, Int#, a#)
finalizeWeak# :: Weak# a -> State# RealWorld -> (#State# RealWorld, Int#, State# RealWorld -> (#State# RealWorld, ()#)#)
touch# :: o -> State# RealWorld -> State# RealWorld
Stable pointers and names
makeStablePtr# :: a -> State# RealWorld -> (#State# RealWorld, StablePtr# a#)
deRefStablePtr# :: StablePtr# a -> State# RealWorld -> (#State# RealWorld, a#)
eqStablePtr# :: StablePtr# a -> StablePtr# a -> Int#
makeStableName# :: a -> State# RealWorld -> (#State# RealWorld, StableName# a#)
eqStableName# :: StableName# a -> StableName# a -> Int#
stableNameToInt# :: StableName# a -> Int#
Unsafe pointer equality
reallyUnsafePtrEquality# :: a -> a -> Int#
Parallelism
par# :: a -> Int#
parGlobal# :: a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
parLocal# :: a -> Int# -> Int# -> Int# -> Int# -> b -> Int#
parAt# :: b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
parAtAbs# :: a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
parAtRel# :: a -> Int# -> Int# -> Int# -> Int# -> Int# -> b -> Int#
parAtForNow# :: b -> a -> Int# -> Int# -> Int# -> Int# -> c -> Int#
Tag to enum stuff
Convert back and forth between values of enumerated types and small integers.
dataToTag# :: a -> Int#
tagToEnum# :: Int# -> a
Bytecode operations
Support for the bytecode interpreter and linker.
addrToHValue# :: Addr# -> (#a#)
Convert an Addr# to a followable type.
mkApUpd0# :: BCO# -> (#a#)
newBCO# :: ByteArr# -> ByteArr# -> Array# a -> ByteArr# -> Int# -> ByteArr# -> State# s -> (#State# s, BCO##)
Coercion
unsafeCoerce# :: a -> b is not a primop, but is defined in MkId.lhs.
Produced by Haddock version 0.8