uint16
UInt16: the integers from 0 to 65535, wrapping around as the
machine’s do: fromInt 65536 is 0, fromInt (-1) is 65535. A literal checked at UInt16 is one ((7 : UInt16)).
Import it by a name, import uint16 as UInt16, as the other fixed-width
types’ modules have the same names: UInt16.fromInt, UInt16.minBound. None
of them is the prelude’s: its instances are the prelude’s operators
and functions at UInt16, 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.)
uint16Add
uint16Add : UInt16 -> UInt16 -> UInt16uint16Sub
uint16Sub : UInt16 -> UInt16 -> UInt16uint16Mul
uint16Mul : UInt16 -> UInt16 -> UInt16uint16Div
uint16Div : UInt16 -> UInt16 -> UInt16uint16Rem
uint16Rem : UInt16 -> UInt16 -> UInt16uint16Lt
uint16Lt : UInt16 -> UInt16 -> Booluint16Le
uint16Le : UInt16 -> UInt16 -> Booluint16And
uint16And : UInt16 -> UInt16 -> UInt16uint16Or
uint16Or : UInt16 -> UInt16 -> UInt16uint16Xor
uint16Xor : UInt16 -> UInt16 -> UInt16uint16Shl
uint16Shl : UInt16 -> UInt16 -> UInt16uint16Shr
uint16Shr : UInt16 -> UInt16 -> UInt16uint16Show
uint16Show : UInt16 -> Stringuint16FromInt
uint16FromInt : Int -> UInt16uint16ToInt
uint16ToInt : UInt16 -> IntminBound
minBound : UInt16The least.
maxBound
maxBound : UInt16The greatest.
add
add : UInt16 -> UInt16 -> UInt16The sum, wrapped around: add maxBound 1 is minBound.
sub
sub : UInt16 -> UInt16 -> UInt16mul
mul : UInt16 -> UInt16 -> UInt16div
div : UInt16 -> UInt16 -> UInt16Division rounding toward zero (as C’s, not as an Int’s /); by 0,
0.
rem
rem : UInt16 -> UInt16 -> UInt16The 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 : UInt16 -> UInt16 -> Boollt
lt : UInt16 -> UInt16 -> Boolle
le : UInt16 -> UInt16 -> BoolfromInt
fromInt : Int -> UInt16The UInt16 an integer wraps around to: equal to it modulo 2^16.
toInt
toInt : UInt16 -> IntrotateLeft
rotateLeft : UInt16 -> Int -> UInt16The bits turned left by n, modulo 16: those shifted out at the top
come in at the bottom, as Go’s bits.RotateLeft16 turns them; by a
negative n, right.
>>> List.map (\n -> toInt (rotateLeft 32769 n : UInt16)) [1, -1, 16]Cons 3 (Cons 49152 (Cons 32769 Nil))rotateRight
rotateRight : UInt16 -> Int -> UInt16The bits turned right by n: rotateLeft x (-n).
>>> toInt (rotateRight 3 1 : UInt16)32769popCount
popCount : UInt16 -> IntHow many of its bits are 1.
>>> List.map (\x -> popCount (x : UInt16)) [0, 7, 65535]Cons 0 (Cons 3 (Cons 16 Nil))bitLength
bitLength : UInt16 -> IntHow many bits it needs: the place of its highest 1, from 1; of 0, 0.
>>> List.map (\x -> bitLength (x : UInt16)) [0, 1, 5, 65535]Cons 0 (Cons 1 (Cons 3 (Cons 16 Nil)))leadingZeros
leadingZeros : UInt16 -> IntHow many 0 bits are above its highest 1: of 0, 16.
>>> List.map (\x -> leadingZeros (x : UInt16)) [0, 1, 32768]Cons 16 (Cons 15 (Cons 0 Nil))trailingZeros
trailingZeros : UInt16 -> IntHow many 0 bits are below its lowest 1: of 0, 16.
>>> List.map (\x -> trailingZeros (x : UInt16)) [0, 1, 12, 32768]Cons 16 (Cons 0 (Cons 2 (Cons 15 Nil)))instanceEqualityUInt16
instance instanceEqualityUInt16 : Equality UInt16instanceDebugUInt16
instance instanceDebugUInt16 : Debug UInt16>>> debug (7 : UInt16)"7"instanceShowUInt16
instance instanceShowUInt16 : Show UInt16As debug writes it.
instanceOrderUInt16
instance instanceOrderUInt16 : Order UInt16instanceAdditionUInt16
instance instanceAdditionUInt16 : Addition UInt16instanceSubtractionUInt16
instance instanceSubtractionUInt16 : Subtraction UInt16instanceMultiplicationUInt16
instance instanceMultiplicationUInt16 : Multiplication UInt16instanceDivisionUInt16
instance instanceDivisionUInt16 : Division UInt16>>> List.map debug ([7 / 2, 7 / 0] : List UInt16)Cons "3" (Cons "0" Nil)instanceRemainderUInt16
instance instanceRemainderUInt16 : Remainder UInt16>>> List.map debug ([7 % 2, 7 % 0, (7 / 0) * 0 + 7 % 0] : List UInt16)Cons "1" (Cons "7" (Cons "7" Nil))instanceNegationUInt16
instance instanceNegationUInt16 : Negation UInt16What, added to it, wraps around to 0: of 1, maxBound.
instanceIsZeroUInt16
instance instanceIsZeroUInt16 : IsZero UInt16instanceBitwiseUInt16
instance instanceBitwiseUInt16 : Bitwise UInt16The bits: shifted left by the second (modulo 16), the bits shifted out lost, and right, zeros shifted in.
>>> debug (and (shiftL 1 3 + 1) (complement 0) * 3 - 2 : UInt16)"25"