fromIntegral -package:backprop

General coercion from Integral types. WARNING: This function performs silent truncation if the result type is not at least as big as the argument's type.
general coercion from integral types
Convert from integral to ring.
Polymorphic version of fromInteger
fromIntegral a == a
Variant of fromIntegral for generalized booleans.
Number fromIntegral uni-operator.
Number fromIntegral uni-operator.
Re-exported fromIntegral, but please give it explicit type to make it obvious if wrapping, etc., may occur. Use toIntegralCrash instead, if possible, because it fails instead of wrapping, etc. In general, it may wrap or otherwise lose information.
Construct and internalizing a FromIntegralTerm.
Converts an Integral value into an interval.
Convert a bounded integeral into a decimal, while performing the necessary scaling
>>> import Numeric.Decimal

>>> fromIntegralDecimalBounded 1234 :: IO (Decimal RoundHalfUp 4 Int)
1234.0000

>>> fromIntegralDecimalBounded 1234 :: IO (Decimal RoundHalfUp 4 Int16)
*** Exception: arithmetic overflow
Pattern synonym for FromIntegralTerm'. Note that using this pattern to construct a Term will do term simplification.
Enumerate an Integral type. enumerateFromIntegral from generates a stream whose first element is from and the successive elements are in increments of 1. The stream is bounded by the size of the Integral type.
>>> Stream.toList $ Stream.take 4 $ Stream.enumerateFromIntegral (0 :: Int)
[0,1,2,3]
Enumerate an Integral type. enumerateFromIntegral from generates a stream whose first element is from and the successive elements are in increments of 1. The stream is bounded by the size of the Integral type.
>>> Stream.toList $ Stream.take 4 $ Stream.enumerateFromIntegral (0 :: Int)
[0,1,2,3]
Like fromIntegral, but errors if a is out of bounds for b. Useful when you "know" a can't be out of bounds, but would like to have your assumptions checked.
  • NB: Check only affects simulation. I.e., no checks will be inserted into the generated HDL
  • NB: fromIntegral is not well suited for Clash as it will go through Integer which is arbitrarily bounded in HDL. Instead use bitCoerce and the Resize class.