Skip to content
heff

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 -> UInt16

uint16Sub

uint16Sub : UInt16 -> UInt16 -> UInt16

uint16Mul

uint16Mul : UInt16 -> UInt16 -> UInt16

uint16Div

uint16Div : UInt16 -> UInt16 -> UInt16

uint16Rem

uint16Rem : UInt16 -> UInt16 -> UInt16

uint16Lt

uint16Lt : UInt16 -> UInt16 -> Bool

uint16Le

uint16Le : UInt16 -> UInt16 -> Bool

uint16And

uint16And : UInt16 -> UInt16 -> UInt16

uint16Or

uint16Or : UInt16 -> UInt16 -> UInt16

uint16Xor

uint16Xor : UInt16 -> UInt16 -> UInt16

uint16Shl

uint16Shl : UInt16 -> UInt16 -> UInt16

uint16Shr

uint16Shr : UInt16 -> UInt16 -> UInt16

uint16Show

uint16Show : UInt16 -> String

uint16FromInt

uint16FromInt : Int -> UInt16

uint16ToInt

uint16ToInt : UInt16 -> Int

minBound

minBound : UInt16

The least.

maxBound

maxBound : UInt16

The greatest.

add

add : UInt16 -> UInt16 -> UInt16

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

sub

sub : UInt16 -> UInt16 -> UInt16

mul

mul : UInt16 -> UInt16 -> UInt16

div

div : UInt16 -> UInt16 -> UInt16

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

rem

rem : UInt16 -> UInt16 -> UInt16

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 : UInt16 -> UInt16 -> Bool

lt

lt : UInt16 -> UInt16 -> Bool

le

le : UInt16 -> UInt16 -> Bool

fromInt

fromInt : Int -> UInt16

The UInt16 an integer wraps around to: equal to it modulo 2^16.

toInt

toInt : UInt16 -> Int

rotateLeft

rotateLeft : UInt16 -> Int -> UInt16

The 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 -> UInt16

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

>>> toInt (rotateRight 3 1 : UInt16)
32769

popCount

popCount : UInt16 -> Int

How 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 -> Int

How 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 -> Int

How 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 -> Int

How 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 UInt16

instanceDebugUInt16

instance instanceDebugUInt16 : Debug UInt16
>>> debug (7 : UInt16)
"7"

instanceShowUInt16

instance instanceShowUInt16 : Show UInt16

As debug writes it.

instanceOrderUInt16

instance instanceOrderUInt16 : Order UInt16

instanceAdditionUInt16

instance instanceAdditionUInt16 : Addition UInt16

instanceSubtractionUInt16

instance instanceSubtractionUInt16 : Subtraction UInt16

instanceMultiplicationUInt16

instance instanceMultiplicationUInt16 : Multiplication UInt16

instanceDivisionUInt16

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 UInt16

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

instanceIsZeroUInt16

instance instanceIsZeroUInt16 : IsZero UInt16

instanceBitwiseUInt16

instance instanceBitwiseUInt16 : Bitwise UInt16

The 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"