On Sat, Mar 27, 2010 at 8:16 PM, Roman Leshchinskiy <r...@cse.unsw.edu.au>wrote:

> On 28/03/2010, at 01:36, Jan-Willem Maessen wrote:
>
> > It's worth pointing out that there's a bit of bang-pattern mysticism
> going on in this conversation (which has not been uncommon of late!).  A
> non-buggy strictness analyzer should expose the strictness of these
> functions without difficulty.
>
> Actually, rangeJ is lazy in i and rangeK is lazy in i and j. GHC does unbox
> everything important here but that needs more optimisations than just
> strictness analysis. You are right, though, that GHC doesn't need bang
> patterns here.
>

Quite right, the condition in rangeK that mentions all variables is under
another condition:

       rangeK :: Int -> Int -> Int -> Int -> Int
       rangeK i j k acc
           | k < 1000 =
               if i * i + j * j + k * k `mod` 7 == 0
               ...

So we need to apply some constructor specialization as well to notice that i
and j are always of the form (Int# i#).

-Jan

Roman
>
>
>
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to