Re: Deprecating fromIntegral

On 22 Sep 2017, at 13:43, Dominic
wrote: Coincidentally, I was playing with this a few days ago. I didn’t seem to have to do anything to get a warning.
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help Prelude Data.Word> :m Data.Int Prelude Data.Int> 0x80000000 :: Int32
<interactive>:27:1: warning: [-Woverflowed-literals] Literal 2147483648 is out of the Int32 range -2147483648..2147483647 If you are trying to write a large negative literal, use NegativeLiterals -2147483648 Prelude Data.Int> :set -XNegativeLiterals Prelude Data.Int> 0x80000000 :: Int32
<interactive>:29:1: warning: [-Woverflowed-literals] Literal 2147483648 is out of the Int32 range -2147483648..2147483647 -2147483648
I am not clear why it wanted me to use NegativeLiterals but still give the same warning. Does anyone understand the intent here?
Message: 1 Date: Fri, 22 Sep 2017 14:14:12 +0200 From: Herbert Valerio Riedel
To: Niklas Hambüchen Cc: Haskell Libraries Subject: Re: Deprecating fromIntegral Message-ID: Content-Type: text/plain; charset="UTF-8" ...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
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>
------------------------------
Subject: Digest Footer
_______________________________________________ Libraries mailing list Libraries@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
------------------------------
End of Libraries Digest, Vol 169, Issue 30 ******************************************
Dominic Steinitz dominic@steinitz.org http://idontgetoutmuch.wordpress.com
participants (1)
-
dominic@steinitz.org