Transforms an integer number to a bounded integral. It returns
Nothing for integers outside the bound of the return type.
>>> integerToBounded @Int 42
Just 42
>>> integerToBounded @Int8 1024
Nothing
>>> integerToBounded @Int (toInteger (minBound :: Int))
Just (-9223372036854775808)
>>> integerToBounded @Int $ (toInteger (minBound :: Int)) - 1
Nothing
>>> integerToBounded @Int (toInteger (maxBound :: Int))
Just 9223372036854775807
>>> integerToBounded @Int $ (toInteger (maxBound :: Int)) + 1
Nothing
If you want to convert
Int or
Word to a bounded type,
take a look at
toIntegralSized function instead.