Skip to content
heff

uint32

UInt32: the integers from 0 to 4294967295, wrapping around as the machine’s do: fromInt 4294967296 is 0, fromInt (-1) is 4294967295. A literal checked at UInt32 is one ((7 : UInt32)). Import it by a name, import uint32 as UInt32, as the other fixed-width types’ modules have the same names: UInt32.fromInt, UInt32.minBound. None of them is the prelude’s: its instances are the prelude’s operators and functions at UInt32, wherever it is imported, by a name or not — x + 1, x / y, -x, x < y, max x y, and x y — so that, opened, it is in the way of none of them at another type. (Another fixed-width type’s value from one goes by way of an Int: toInt, then the other’s fromInt.)

uint32Add

uint32Add : UInt32 -> UInt32 -> UInt32

uint32Sub

uint32Sub : UInt32 -> UInt32 -> UInt32

uint32Mul

uint32Mul : UInt32 -> UInt32 -> UInt32

uint32Div

uint32Div : UInt32 -> UInt32 -> UInt32

uint32Rem

uint32Rem : UInt32 -> UInt32 -> UInt32

uint32Lt

uint32Lt : UInt32 -> UInt32 -> Bool

uint32Le

uint32Le : UInt32 -> UInt32 -> Bool

uint32And

uint32And : UInt32 -> UInt32 -> UInt32

uint32Or

uint32Or : UInt32 -> UInt32 -> UInt32

uint32Xor

uint32Xor : UInt32 -> UInt32 -> UInt32

uint32Shl

uint32Shl : UInt32 -> UInt32 -> UInt32

uint32Shr

uint32Shr : UInt32 -> UInt32 -> UInt32

uint32Show

uint32Show : UInt32 -> String

uint32FromInt

uint32FromInt : Int -> UInt32

uint32ToInt

uint32ToInt : UInt32 -> Int

minBound

minBound : UInt32

The least.

maxBound

maxBound : UInt32

The greatest.

add

add : UInt32 -> UInt32 -> UInt32

The sum, wrapped around: add maxBound 1 is minBound.

sub

sub : UInt32 -> UInt32 -> UInt32

mul

mul : UInt32 -> UInt32 -> UInt32

div

div : UInt32 -> UInt32 -> UInt32

Division rounding toward zero (as C’s, not as an Int’s /); by 0, 0.

rem

rem : UInt32 -> UInt32 -> UInt32

The remainder of div; by 0, the dividend, so that add (mul (div x y) y) (rem x y) is x whatever y is.

eq

eq : UInt32 -> UInt32 -> Bool

lt

lt : UInt32 -> UInt32 -> Bool

le

le : UInt32 -> UInt32 -> Bool

fromInt

fromInt : Int -> UInt32

The UInt32 an integer wraps around to: equal to it modulo 2^32.

toInt

toInt : UInt32 -> Int

rotateLeft

rotateLeft : UInt32 -> Int -> UInt32

The bits turned left by n, modulo 32: those shifted out at the top come in at the bottom, as Go’s bits.RotateLeft32 turns them; by a negative n, right.

>>> List.map (\n -> toInt (rotateLeft 2147483649 n : UInt32)) [1, -1, 32]
Cons 3 (Cons 3221225472 (Cons 2147483649 Nil))

rotateRight

rotateRight : UInt32 -> Int -> UInt32

The bits turned right by n: rotateLeft x (-n).

>>> toInt (rotateRight 3 1 : UInt32)
2147483649

popCount

popCount : UInt32 -> Int

How many of its bits are 1.

>>> List.map (\x -> popCount (x : UInt32)) [0, 7, 4294967295]
Cons 0 (Cons 3 (Cons 32 Nil))

bitLength

bitLength : UInt32 -> Int

How many bits it needs: the place of its highest 1, from 1; of 0, 0.

>>> List.map (\x -> bitLength (x : UInt32)) [0, 1, 5, 4294967295]
Cons 0 (Cons 1 (Cons 3 (Cons 32 Nil)))

leadingZeros

leadingZeros : UInt32 -> Int

How many 0 bits are above its highest 1: of 0, 32.

>>> List.map (\x -> leadingZeros (x : UInt32)) [0, 1, 2147483648]
Cons 32 (Cons 31 (Cons 0 Nil))

trailingZeros

trailingZeros : UInt32 -> Int

How many 0 bits are below its lowest 1: of 0, 32.

>>> List.map (\x -> trailingZeros (x : UInt32)) [0, 1, 12, 2147483648]
Cons 32 (Cons 0 (Cons 2 (Cons 31 Nil)))

instanceEqualityUInt32

instance instanceEqualityUInt32 : Equality UInt32

instanceDebugUInt32

instance instanceDebugUInt32 : Debug UInt32
>>> debug (7 : UInt32)
"7"

instanceShowUInt32

instance instanceShowUInt32 : Show UInt32

As debug writes it.

instanceOrderUInt32

instance instanceOrderUInt32 : Order UInt32

instanceAdditionUInt32

instance instanceAdditionUInt32 : Addition UInt32

instanceSubtractionUInt32

instance instanceSubtractionUInt32 : Subtraction UInt32

instanceMultiplicationUInt32

instance instanceMultiplicationUInt32 : Multiplication UInt32

instanceDivisionUInt32

instance instanceDivisionUInt32 : Division UInt32
>>> List.map debug ([7 / 2, 7 / 0] : List UInt32)
Cons "3" (Cons "0" Nil)

instanceRemainderUInt32

instance instanceRemainderUInt32 : Remainder UInt32
>>> List.map debug ([7 % 2, 7 % 0, (7 / 0) * 0 + 7 % 0] : List UInt32)
Cons "1" (Cons "7" (Cons "7" Nil))

instanceNegationUInt32

instance instanceNegationUInt32 : Negation UInt32

What, added to it, wraps around to 0: of 1, maxBound.

instanceIsZeroUInt32

instance instanceIsZeroUInt32 : IsZero UInt32

instanceBitwiseUInt32

instance instanceBitwiseUInt32 : Bitwise UInt32

The bits: shifted left by the second (modulo 32), the bits shifted out lost, and right, zeros shifted in.

>>> debug (and (shiftL 1 3 + 1) (complement 0) * 3 - 2 : UInt32)
"25"