| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Unwitch.Convert.Int
Contents
Description
Conversions from Int.
Synopsis
- toInt8 :: Int -> Maybe Int8
- toInt16 :: Int -> Maybe Int16
- toInt32 :: Int -> Maybe Int32
- toInt64 :: Int -> Int64
- toInteger :: Int -> Integer
- toWord8 :: Int -> Maybe Word8
- toWord16 :: Int -> Maybe Word16
- toWord32 :: Int -> Maybe Word32
- toWord64 :: Int -> Maybe Word64
- toWord :: Int -> Maybe Word
- toNatural :: Int -> Either Overflows Natural
- toFloat :: Int -> Either Overflows Float
- toDouble :: Int -> Either Overflows Double
- toCInt :: Int -> Maybe CInt
- toInt8# :: Int -> (# Int8 | (# #) #)
- toInt16# :: Int -> (# Int16 | (# #) #)
- toInt32# :: Int -> (# Int32 | (# #) #)
- toWord8# :: Int -> (# Word8 | (# #) #)
- toWord16# :: Int -> (# Word16 | (# #) #)
- toWord32# :: Int -> (# Word32 | (# #) #)
- toWord64# :: Int -> (# Word64 | (# #) #)
- toWord# :: Int -> (# Word | (# #) #)
- toNatural# :: Int -> (# Overflows | Natural #)
- toFloat# :: Int -> (# Overflows | Float #)
- toDouble# :: Int -> (# Overflows | Double #)
Conversions
toFloat :: Int -> Either Overflows Float Source #
Checked conversion, fails if outside exact float integer range (+/-16777215).
toDouble :: Int -> Either Overflows Double Source #
Checked conversion, fails if outside exact double integer range (+/-9007199254740991).
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.
toWord8# :: Int -> (# Word8 | (# #) #) Source #
Signed->unsigned narrow, roundtrip via Word# back to Int#
toWord16# :: Int -> (# Word16 | (# #) #) Source #
Signed->unsigned narrow, roundtrip via Word# back to Int#