unwitch-3.0.0: converts between primitives
Safe HaskellNone
LanguageHaskell2010

Unwitch.Convert.Int16

Description

Conversions from Int16.

Synopsis

Conversions

toNatural :: Int16 -> Either Overflows Natural Source #

Signed-to-unsigned conversion, returns Left Underflow for negative values.

toCInt :: Int16 -> CInt Source #

Widening conversion via Int32, always succeeds.

Unboxed conversions

These use GHC unboxed types and unboxed sums for zero-allocation failure handling. Requires the MagicHash, UnboxedSums and UnboxedTuples language extensions. See the GHC manual on unboxed types.

toInt8# :: Int16 -> (# Int8 | (# #) #) Source #

Signed narrowing, roundtrip at Int#

toWord8# :: Int16 -> (# Word8 | (# #) #) Source #

Signed->unsigned narrow, roundtrip via Word# back to Int#

toWord16# :: Int16 -> (# Word16 | (# #) #) Source #

Signed->unsigned, check non-negative

toWord32# :: Int16 -> (# Word32 | (# #) #) Source #

Signed->unsigned, check non-negative

toWord64# :: Int16 -> (# Word64 | (# #) #) Source #

Signed->unsigned, check non-negative

toWord# :: Int16 -> (# Word | (# #) #) Source #

Signed->unsigned, check non-negative

toNatural# :: Int16 -> (# Overflows | Natural #) Source #

Check non-negative, construct NS directly