Skip to content
heff

int16

Int16: the integers from -32768 to 32767, wrapping around as the machine’s do (two’s complement): fromInt 32768 is -32768. A literal checked at Int16 is one ((7 : Int16)). Import it by a name, import int16 as Int16, as the other fixed-width types’ modules have the same names: Int16.fromInt, Int16.minBound. None of them is the prelude’s: its instances are the prelude’s operators and functions at Int16, 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.)

int16Add

int16Add : Int16 -> Int16 -> Int16

int16Sub

int16Sub : Int16 -> Int16 -> Int16

int16Mul

int16Mul : Int16 -> Int16 -> Int16

int16Div

int16Div : Int16 -> Int16 -> Int16

int16Rem

int16Rem : Int16 -> Int16 -> Int16

int16Lt

int16Lt : Int16 -> Int16 -> Bool

int16Le

int16Le : Int16 -> Int16 -> Bool

int16And

int16And : Int16 -> Int16 -> Int16

int16Or

int16Or : Int16 -> Int16 -> Int16

int16Xor

int16Xor : Int16 -> Int16 -> Int16

int16Shl

int16Shl : Int16 -> Int16 -> Int16

int16Shr

int16Shr : Int16 -> Int16 -> Int16

int16Show

int16Show : Int16 -> String

int16FromInt

int16FromInt : Int -> Int16

int16ToInt

int16ToInt : Int16 -> Int

minBound

minBound : Int16

The least.

maxBound

maxBound : Int16

The greatest.

add

add : Int16 -> Int16 -> Int16

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

sub

sub : Int16 -> Int16 -> Int16

mul

mul : Int16 -> Int16 -> Int16

div

div : Int16 -> Int16 -> Int16

Division rounding toward zero (as C’s, not as an Int’s /); by 0, 0. By -1 it is a negation, wrapping around: of minBound, itself.

rem

rem : Int16 -> Int16 -> Int16

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

eq

eq : Int16 -> Int16 -> Bool

lt

lt : Int16 -> Int16 -> Bool

le

le : Int16 -> Int16 -> Bool

fromInt

fromInt : Int -> Int16

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

toInt

toInt : Int16 -> Int

instanceEqualityInt16

instance instanceEqualityInt16 : Equality Int16

instanceDebugInt16

instance instanceDebugInt16 : Debug Int16
>>> debug (7 : Int16)
"7"

instanceShowInt16

instance instanceShowInt16 : Show Int16

As debug writes it.

instanceOrderInt16

instance instanceOrderInt16 : Order Int16

instanceAdditionInt16

instance instanceAdditionInt16 : Addition Int16

instanceSubtractionInt16

instance instanceSubtractionInt16 : Subtraction Int16

instanceMultiplicationInt16

instance instanceMultiplicationInt16 : Multiplication Int16

instanceDivisionInt16

instance instanceDivisionInt16 : Division Int16
>>> List.map debug ([7 / 2, -7 / 2, 7 / 0, minBound / -1] : List Int16)
Cons "3" (Cons "-3" (Cons "0" (Cons "-32768" Nil)))

instanceRemainderInt16

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

instanceNegationInt16

instance instanceNegationInt16 : Negation Int16

The integer of the other sign, wrapped around: of minBound, itself.

instanceIsZeroInt16

instance instanceIsZeroInt16 : IsZero Int16

instanceBitwiseInt16

instance instanceBitwiseInt16 : Bitwise Int16

The bits, as two’s complement has them: shifted left by the second (modulo 16), the bits shifted out lost, and right, the sign copied in; by a negative second, the other way (shiftL x -n is shiftR x n).

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