Need workaround for lack of fromIntegral/Int->Word rules in 7.4.2

Johan Tibell johan.tibell at gmail.com
Mon Dec 17 16:07:21 CET 2012


This compiles badly in 7.4.2:

    f :: Int -> Word
    f = fromIntegral

I need a workaround.

On Mon, Dec 17, 2012 at 2:35 AM, Simon Peyton-Jones
<simonpj at microsoft.com> wrote:
> I don't understand the problem clearly enough to help.  Can you give a concrete example?
>
> Simon
>
> | -----Original Message-----
> | From: glasgow-haskell-users-bounces at haskell.org [mailto:glasgow-haskell-
> | users-bounces at haskell.org] On Behalf Of Johan Tibell
> | Sent: 14 December 2012 23:17
> | To: glasgow-haskell-users
> | Subject: Need workaround for lack of fromIntegral/Int->Word rules in
> | 7.4.2
> |
> | I'm trying to work around the lack of some fromIntegral/Int->Word rules
> | in 7.4.2. I tried something like:
> |
> | int2Word :: Int -> Word
> | #if defined(__GLASGOW_HASKELL__)
> | int2Word (I# i#) = W# (int2Word# i#)
> | #else
> | int2Word = fromIntegral
> | #endif
> |
> | {-# RULES "fromIntegral/Int->Word" fromIntegral = int2Word #-}
> |
> | but that didn't work as some fromSmallInteger and integerToWord function
> | calls got inserted before my rule had a chance to fire. Can anyone think
> | of a workaround that would work with 7.4.2?
> |
> | P.S. The reason I want this workaround is that some of my users are
> | stuck on 7.4.2 and this regression is affecting them quite badly, making
> | me want to try to fix it in my library.
> |
> | Cheers,
> | Johan
> |
> | _______________________________________________
> | Glasgow-haskell-users mailing list
> | Glasgow-haskell-users at haskell.org
> | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>



More information about the Glasgow-haskell-users mailing list