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

Johan Tibell johan.tibell at
Sat Dec 15 00:16:35 CET 2012

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#)
int2Word = fromIntegral

{-# 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.


More information about the Glasgow-haskell-users mailing list