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 -> UInt32uint32Sub
uint32Sub : UInt32 -> UInt32 -> UInt32uint32Mul
uint32Mul : UInt32 -> UInt32 -> UInt32uint32Div
uint32Div : UInt32 -> UInt32 -> UInt32uint32Rem
uint32Rem : UInt32 -> UInt32 -> UInt32uint32Lt
uint32Lt : UInt32 -> UInt32 -> Booluint32Le
uint32Le : UInt32 -> UInt32 -> Booluint32And
uint32And : UInt32 -> UInt32 -> UInt32uint32Or
uint32Or : UInt32 -> UInt32 -> UInt32uint32Xor
uint32Xor : UInt32 -> UInt32 -> UInt32uint32Shl
uint32Shl : UInt32 -> UInt32 -> UInt32uint32Shr
uint32Shr : UInt32 -> UInt32 -> UInt32uint32Show
uint32Show : UInt32 -> Stringuint32FromInt
uint32FromInt : Int -> UInt32uint32ToInt
uint32ToInt : UInt32 -> IntminBound
minBound : UInt32The least.
maxBound
maxBound : UInt32The greatest.
add
add : UInt32 -> UInt32 -> UInt32The sum, wrapped around: add maxBound 1 is minBound.
sub
sub : UInt32 -> UInt32 -> UInt32mul
mul : UInt32 -> UInt32 -> UInt32div
div : UInt32 -> UInt32 -> UInt32Division rounding toward zero (as C’s, not as an Int’s /); by 0,
0.
rem
rem : UInt32 -> UInt32 -> UInt32The 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 -> Boollt
lt : UInt32 -> UInt32 -> Boolle
le : UInt32 -> UInt32 -> BoolfromInt
fromInt : Int -> UInt32The UInt32 an integer wraps around to: equal to it modulo 2^32.
toInt
toInt : UInt32 -> IntrotateLeft
rotateLeft : UInt32 -> Int -> UInt32The 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 -> UInt32The bits turned right by n: rotateLeft x (-n).
>>> toInt (rotateRight 3 1 : UInt32)2147483649popCount
popCount : UInt32 -> IntHow 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 -> IntHow 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 -> IntHow 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 -> IntHow 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 UInt32instanceDebugUInt32
instance instanceDebugUInt32 : Debug UInt32>>> debug (7 : UInt32)"7"instanceShowUInt32
instance instanceShowUInt32 : Show UInt32As debug writes it.
instanceOrderUInt32
instance instanceOrderUInt32 : Order UInt32instanceAdditionUInt32
instance instanceAdditionUInt32 : Addition UInt32instanceSubtractionUInt32
instance instanceSubtractionUInt32 : Subtraction UInt32instanceMultiplicationUInt32
instance instanceMultiplicationUInt32 : Multiplication UInt32instanceDivisionUInt32
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 UInt32What, added to it, wraps around to 0: of 1, maxBound.
instanceIsZeroUInt32
instance instanceIsZeroUInt32 : IsZero UInt32instanceBitwiseUInt32
instance instanceBitwiseUInt32 : Bitwise UInt32The 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"