[Haskell-cafe] GHC predictability

Andrew Coppin andrewcoppin at btinternet.com
Tue May 13 17:01:28 EDT 2008


Don Stewart wrote:
> Andrew, would you say you understand the original problem of why
>
>     mean xs = sum xs / fromIntegral (length xs)
>
> was a bad idea now? Or why the left folds were a better solution?
>   

That definition of mean is wrong because it traverses the list twice. 
(Curiosity: would traversing it twice in parallel work any better?) As 
for the folds - I always *always* mix up left and right folds. Every 
single damn time I want a fold I have to look it up to see which one I 
want. I had a similar problem with learning to drive, by the way... the 
consequences there are of course much more serious than just crashing 
your _computer_...

It was probably a poor example. The point I was attempting to make is 
that in Haskell, very subtle little things can have an unexpectedly 
profound effect. If you don't know what you're supposed to be looking 
for, it can be really hard to see why your program is performing badly.

For what it's worth, I think I *do* currently have a reasonably gasp of 
how lazzy evaluation works, normal order reduction, graph machines, and 
so on. And yet, I still have trouble making my code go fast sometimes. 
As I said in another post, if I can track down some *specific* programs 
I've written and had problems with, maybe we can have a more meaningful 
debate about it.



More information about the Haskell-Cafe mailing list