uint8
UInt8: the integers from 0 to 255, wrapping around as the
machine’s do: fromInt 256 is 0, fromInt (-1) is 255. A literal checked at UInt8 is one ((7 : UInt8)).
Import it by a name, import uint8 as UInt8, as the other fixed-width
types’ modules have the same names: UInt8.fromInt, UInt8.minBound. None
of them is the prelude’s: its instances are the prelude’s operators
and functions at UInt8, 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.)
uint8Add
uint8Add : UInt8 -> UInt8 -> UInt8uint8Sub
uint8Sub : UInt8 -> UInt8 -> UInt8uint8Mul
uint8Mul : UInt8 -> UInt8 -> UInt8uint8Div
uint8Div : UInt8 -> UInt8 -> UInt8uint8Rem
uint8Rem : UInt8 -> UInt8 -> UInt8uint8Lt
uint8Lt : UInt8 -> UInt8 -> Booluint8Le
uint8Le : UInt8 -> UInt8 -> Booluint8And
uint8And : UInt8 -> UInt8 -> UInt8uint8Or
uint8Or : UInt8 -> UInt8 -> UInt8uint8Xor
uint8Xor : UInt8 -> UInt8 -> UInt8uint8Shl
uint8Shl : UInt8 -> UInt8 -> UInt8uint8Shr
uint8Shr : UInt8 -> UInt8 -> UInt8uint8Show
uint8Show : UInt8 -> StringminBound
minBound : UInt8The least.
maxBound
maxBound : UInt8The greatest.
add
add : UInt8 -> UInt8 -> UInt8The sum, wrapped around: add maxBound 1 is minBound.
sub
sub : UInt8 -> UInt8 -> UInt8mul
mul : UInt8 -> UInt8 -> UInt8div
div : UInt8 -> UInt8 -> UInt8Division rounding toward zero (as C’s, not as an Int’s /); by 0,
0.
rem
rem : UInt8 -> UInt8 -> UInt8The 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 : UInt8 -> UInt8 -> Boollt
lt : UInt8 -> UInt8 -> Boolle
le : UInt8 -> UInt8 -> BoolfromInt
fromInt : Int -> UInt8The UInt8 an integer wraps around to: equal to it modulo 2^8.
toInt
toInt : UInt8 -> IntrotateLeft
rotateLeft : UInt8 -> Int -> UInt8The bits turned left by n, modulo 8: those shifted out at the top
come in at the bottom, as Go’s bits.RotateLeft8 turns them; by a
negative n, right.
>>> List.map (\n -> toInt (rotateLeft 129 n : UInt8)) [1, -1, 8]Cons 3 (Cons 192 (Cons 129 Nil))rotateRight
rotateRight : UInt8 -> Int -> UInt8The bits turned right by n: rotateLeft x (-n).
>>> toInt (rotateRight 3 1 : UInt8)129popCount
popCount : UInt8 -> IntHow many of its bits are 1.
>>> List.map (\x -> popCount (x : UInt8)) [0, 7, 255]Cons 0 (Cons 3 (Cons 8 Nil))bitLength
bitLength : UInt8 -> IntHow many bits it needs: the place of its highest 1, from 1; of 0, 0.
>>> List.map (\x -> bitLength (x : UInt8)) [0, 1, 5, 255]Cons 0 (Cons 1 (Cons 3 (Cons 8 Nil)))leadingZeros
leadingZeros : UInt8 -> IntHow many 0 bits are above its highest 1: of 0, 8.
>>> List.map (\x -> leadingZeros (x : UInt8)) [0, 1, 128]Cons 8 (Cons 7 (Cons 0 Nil))trailingZeros
trailingZeros : UInt8 -> IntHow many 0 bits are below its lowest 1: of 0, 8.
>>> List.map (\x -> trailingZeros (x : UInt8)) [0, 1, 12, 128]Cons 8 (Cons 0 (Cons 2 (Cons 7 Nil)))instanceEqualityUInt8
instance instanceEqualityUInt8 : Equality UInt8instanceDebugUInt8
instance instanceDebugUInt8 : Debug UInt8>>> debug (7 : UInt8)"7"instanceShowUInt8
instance instanceShowUInt8 : Show UInt8As debug writes it.
instanceOrderUInt8
instance instanceOrderUInt8 : Order UInt8instanceAdditionUInt8
instance instanceAdditionUInt8 : Addition UInt8instanceSubtractionUInt8
instance instanceSubtractionUInt8 : Subtraction UInt8instanceMultiplicationUInt8
instance instanceMultiplicationUInt8 : Multiplication UInt8instanceDivisionUInt8
instance instanceDivisionUInt8 : Division UInt8>>> List.map debug ([7 / 2, 7 / 0] : List UInt8)Cons "3" (Cons "0" Nil)instanceRemainderUInt8
instance instanceRemainderUInt8 : Remainder UInt8>>> List.map debug ([7 % 2, 7 % 0, (7 / 0) * 0 + 7 % 0] : List UInt8)Cons "1" (Cons "7" (Cons "7" Nil))instanceNegationUInt8
instance instanceNegationUInt8 : Negation UInt8What, added to it, wraps around to 0: of 1, maxBound.
instanceIsZeroUInt8
instance instanceIsZeroUInt8 : IsZero UInt8instanceBitwiseUInt8
instance instanceBitwiseUInt8 : Bitwise UInt8The bits: shifted left by the second (modulo 8), the bits shifted out lost, and right, zeros shifted in.
>>> debug (and (shiftL 1 3 + 1) (complement 0) * 3 - 2 : UInt8)"25"