RE: Need workaround for lack of fromIntegral/Int->Word rules in 7.4.2
| Turns out that I need a larger example to trigger the bug. I can | reliable trigger it using the unordered-containers library. I won't bore | you with the details. The workaround I need is this: | | forall x. integerToWord (smallInteger x) = int2Word# x So why not just add that rule (perhaps with S# rather than smallInteger)? I don't think I can help without a concrete example, sorry. (Even then, I don't know whether it'll be possible to work around 7.4.2. It depends on what is not working.) Simon ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Need workaround for lack of fromIntegral/Int->Word rules in 7.4.2
Hi, Turns out that I need a larger example to trigger the bug. I can reliable trigger it using the unordered-containers library. I won't bore you with the details. The workaround I need is this: forall x. integerToWord (smallInteger x) = int2Word# x ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Need workaround for lack of fromIntegral/Int->Word rules in 7.4.2
On Montag, 17. Dezember 2012, 07:07:21, Johan Tibell wrote: > This compiles badly in 7.4.2: > > f :: Int -> Word > f = fromIntegral > > I need a workaround. Mine produces (with optimisations, of course) Convert.f :: GHC.Types.Int -> GHC.Word.Word [GblId, Arity=1, Caf=NoCafRefs, Str=DmdType U(L)m, Unf=Unf{Src=InlineStable, TopLvl=True, Arity=1, Value=True, ConLike=True, Cheap=True, Expandable=True, Guidance=ALWAYS_IF(unsat_ok=True,boring_ok=False) Tmpl= \ (ds_asy [Occ=Once!] :: GHC.Types.Int) -> case ds_asy of _ { GHC.Types.I# x#_asB [Occ=Once] -> GHC.Word.W# (GHC.Prim.int2Word# x#_asB) }}] Convert.f = \ (ds_asy :: GHC.Types.Int) -> case ds_asy of _ { GHC.Types.I# x#_asB -> GHC.Word.W# (GHC.Prim.int2Word# x#_asB) } which is what one would expect. And all of 6.12.3, 7.0.2, 7.0.4, 7.2.1, 7.2.2, 7.4.1, 7.4.2, 7.6.1 agree on that. I think there is some context needed to nail the problem. ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Need workaround for lack of fromIntegral/Int->Word rules in 7.4.2
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 wrote: > I don't understand the problem clearly enough to help. Can you give a > concrete example? > > Simon > > | -Original Message- > | From: glasgow-haskell-users-boun...@haskell.org [mailto:glasgow-haskell- > | users-boun...@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@haskell.org > | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users > ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: Need workaround for lack of fromIntegral/Int->Word rules in 7.4.2
I don't understand the problem clearly enough to help. Can you give a concrete example? Simon | -Original Message- | From: glasgow-haskell-users-boun...@haskell.org [mailto:glasgow-haskell- | users-boun...@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@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
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@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users