Add function for size-checked conversion of Integral types

The new function `Data.Bits.toIntegralSized` provides a similar
functionality to `fromIntegral` but adds validation that the
argument fits in the result type's size.

The implementation of `toIntegralSized` has been derived from `intCastMaybe`
(which is part of Herbert Valerio Riedel's `int-cast` package,
see http://hackage.haskell.org/package/int-cast)

Addresses #9816

Reviewed By: ekmett, austin

Differential Revision: https://phabricator.haskell.org/D512