Re: [Haskell-cafe] Reasoning about performance

2013-09-10 Thread Scott Pakin
On 09/03/2013 06:09 PM, Dan Burton wrote: Here's a fun alternative for you to benchmark, using an old trick. I kind of doubt that this one will optimize as nicely as the others, but I am by no means an optimization guru: allPairsS :: [a] - [(a, a)] allPairsS xs = go xs [] where go [] = id

Re: [Haskell-cafe] Reasoning about performance

2013-09-04 Thread Scott Pakin
On 09/03/2013 06:02 PM, Carter Schonwald wrote: It's also worth adding that ghci does a lot less optimization than ghc. Yes, I discovered that before I posted. Note from my initial message that I used ghc to compile, then loaded the compiled module into ghci: Prelude :!ghc -c -O2

Re: [Haskell-cafe] Reasoning about performance

2013-09-04 Thread Scott Pakin
On 09/03/2013 05:43 PM, Bob Ippolito wrote: Haskell's non-strict evaluation can often lead to unexpected results when doing tail recursion if you're used to strict functional programming languages. In order to get the desired behavior you will need to force the accumulator (with something

[Haskell-cafe] Reasoning about performance

2013-09-03 Thread Scott Pakin
I'm a Haskell beginner, and I'm baffled trying to reason about code performance, at least with GHC. For a program I'm writing I needed to find all pairs of elements of a list. That is, given the list ABCD I wanted to wind up with the list