Deprecating fromIntegral

Herbert Valerio Riedel hvriedel at gmail.com
Fri Sep 22 12:14:12 UTC 2017


...there's one minor detail I'd like to point out as it doesn't seem
to have been mentioned so far:

On Thu, Sep 21, 2017 at 5:34 PM, Niklas Hamb├╝chen <mail at nh2.me> wrote:

> (Though, in practice the current `fromInteger is not partial, e.g.
> `(fromInteger 256 :: Word8) == 0` without error

That's true. However, here's something you can do already now with
recent GHCs which gives turns literal-overflows GHC is able to detect into
hard compile errors:


  $ ghci -Wall -Werror=overflowed-literals
  GHCi, version 8.2.1: http://www.haskell.org/ghc/  :? for help
  Prelude> (256 :: Data.Word.Word8) == 0

  <interactive>:1:2: warning: [-Woverflowed-literals]
      Literal 256 is out of the GHC.Word.Word8 range 0..255

  <no location info>: error:
  Failing due to -Werror.
  Prelude>


More information about the Libraries mailing list