[Haskell-cafe] forLoop + strict State monad is much faster than foldl'

Patrick Wheeler patrick.john.wheeler at gmail.com
Thu May 1 14:00:57 UTC 2014

Int has a tight loop for `EnumFromTo`

On the other hand look at `EnumFromTo` for word32

It calls `integralEnumFromTo`

Which is

:: Integral a => a -> a -> [a]
n m = map fromInteger [toInteger n .. toInteger m]

That is right you get converted to an Integer, then back again.


This seems to be the problem with all loops that use `Word32` and

It looks like you could add a better `EnumFromTo` for `Word32` and you
would close the gap between the loops that are using `EnumFromTo` and those
that are not.


On Tue, Apr 29, 2014 at 11:35 AM, Niklas Hambüchen <mail at nh2.me> wrote:

> Interestingly, the discrimination against Word32 does not end here:
> When compiling with -fllvm
> (
> http://htmlpreview.github.io/?https://github.com/nh2/loop/blob/master/results/bench-foldl-and-iorefs-are-slow-llvm.html
> ),
> we can see that the forLoop + strict State monad is completely compiled
> away to a no-op for Int, but not for Word32.
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

Patrick Wheeler
Patrick.John.Wheeler at gmail.com
Patrick.J.Wheeler at rice.edu
Patrick.Wheeler at colorado.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140501/cdc25d7e/attachment.html>

More information about the Haskell-Cafe mailing list