[Haskell-cafe] Profiling nested case

Mitar mmitar at gmail.com
Fri Jul 18 08:23:41 EDT 2008


Hi!

On Sat, Jul 12, 2008 at 3:33 AM, Max Bolingbroke
<batterseapower at hotmail.com> wrote:
> If findColor had been a function defined in terms of foldr rather than
> using explicit recursion, then theres a good chance GHC 6.9 would have
> fused it with the list to yield your optimized, loop unrolled,
> version:

My first version was with msum. Is this also covered by this fusion?

(And it is interesting that my own recursion version is faster than
the version with msum. Why?)

> Incidentally, if in your most recent email castRayScene2 was your only
> used of castRay, GHC would have inlined the whole definition into that
> use site and you would have got castRayScene1 back again.

It is a little more tricky. I choose in an IO monad which scene it
will render (selected by a program argument). So at compile time it
does not yet know which one it will use. But there is a finite number
of possibilities (in my case two) - why not inline both versions and
at run time choose one?


Mitar


More information about the Haskell-Cafe mailing list