Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-06 Thread Lennart Augustsson
I tried your example in GHC 6.10 and isum appears to work fine. The type of 1000 gets defaulted to Integer, a specialized version of isum for Integer is then created, the strictness analyzer determines that isum is strict in s, and the code generator produces a loop. (If you want to look at

Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-06 Thread Patai Gergely
I tried your example in GHC 6.10 and isum appears to work fine. The type of 1000 gets defaulted to Integer, a specialized version of isum for Integer is then created, the strictness analyzer determines that isum is strict in s, and the code generator produces a loop. (If you want to look

Re: Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-05 Thread Kim-Ee Yeoh
Luke Palmer-2 wrote: I would like to know or to develop a way to allow abstract analysis of time and space complexity. In the same way that type inference and strictness analysis can be seen as instances of abstract interpretation, so can complexity inference. I agree that the interplay

Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-04 Thread Kim-Ee Yeoh
David Menendez-2 wrote: On Mon, 3 Nov 2008, Luke Palmer wrote: I was actually being an annoying purist. f is strict means f _|_ = _|_, so strictness is a semantic idea, not an operational one. I think Luke was commenting on the terminology, not the optimization. We have a tendency to

Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-04 Thread Ketil Malde
Patai Gergely [EMAIL PROTECTED] writes: My only problem is that if I try to write a program without thinking about performance first and not bothering with annotations as long as it works, I end up with something that's practically impossible to profile as the costs spread everywhere. I

Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-04 Thread Patai Gergely
Thanks everyone for the answers. I understood the underlying mechanism, and I did see that turning on optimisation helps, as I said in the comments. I just wasn't aware that this analysis is not turned on by default, my bad for not reading the FM. So the final verdict is that type and strictness

Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-04 Thread Derek Elkins
On Tue, 2008-11-04 at 12:18 +0100, Patai Gergely wrote: Thanks everyone for the answers. I understood the underlying mechanism, and I did see that turning on optimisation helps, as I said in the comments. I just wasn't aware that this analysis is not turned on by default, my bad for not

Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-04 Thread Lennart Augustsson
Nonsense, isum is strict in s. If s is bottom, isum will always return bottom. This is the definition of being strict. -- Lennart On Mon, Nov 3, 2008 at 10:35 PM, Don Stewart [EMAIL PROTECTED] wrote: frantisek.kocun: yet I need to add a $! to the recursive call of isum to get a truly

Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-03 Thread Derek Elkins
On Mon, 2008-11-03 at 13:31 +0100, Patai Gergely wrote: Hi everyone, I was experimenting with simple accumulator functions, and found that an apparently tail recursive function can easily fill the stack. Playing around with ghc and jhc gave consistently unpleasant results. Look at this

Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-03 Thread Don Stewart
patai_gergely: Hi everyone, I was experimenting with simple accumulator functions, and found that an apparently tail recursive function can easily fill the stack. Playing around with ghc and jhc gave consistently unpleasant results. Look at this program: %%% -- ghc: no, ghc

Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-03 Thread frantisek kocun
yet I need to add a $! to the recursive call of isum to get a truly iterative ??? Wait a minute Patai. How would you do that? I'm only beginner I thought I can only add strict ! to data parameters. But to make isum function strict would be helpful. Thanks On Mon, Nov 3, 2008 at 7:36 PM, Don

Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-03 Thread Don Stewart
frantisek.kocun: yet I need to add a $! to the recursive call of isum to get a truly iterative ??? Wait a minute Patai. How would you do that? I'm only beginner I thought I can only add strict ! to data parameters. But to make isum function strict would be helpful.

Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-03 Thread Luke Palmer
On Mon, Nov 3, 2008 at 2:35 PM, Don Stewart [EMAIL PROTECTED] wrote: Consider this program, isum 0 s = s isum n s = isum (n-1) (s+n) main = case isum 1000 0 {- rsum 1000 -} of 0 - print 0 x - print x

Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-03 Thread Luke Palmer
On Mon, Nov 3, 2008 at 2:49 PM, Luke Palmer [EMAIL PROTECTED] wrote: I am confused about your usage of strict. Optimizations are not supposed to change semantics, so I don't know how it is possible to make a function strict by turning on optimizations. This function was always strict in s,

Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-03 Thread Don Stewart
lrpalmer: On Mon, Nov 3, 2008 at 2:35 PM, Don Stewart [EMAIL PROTECTED] wrote: Consider this program, isum 0 s = s isum n s = isum (n-1) (s+n) main = case isum 1000 0 {- rsum 1000 -} of 0 - print 0

Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-03 Thread Luke Palmer
On Mon, Nov 3, 2008 at 2:54 PM, Don Stewart [EMAIL PROTECTED] wrote: lrpalmer: On Mon, Nov 3, 2008 at 2:35 PM, Don Stewart [EMAIL PROTECTED] wrote: Consider this program, isum 0 s = s isum n s = isum (n-1) (s+n) main = case isum 1000 0 {- rsum

Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-03 Thread Henning Thielemann
On Mon, 3 Nov 2008, Luke Palmer wrote: On Mon, Nov 3, 2008 at 2:54 PM, Don Stewart [EMAIL PROTECTED] wrote: Optimisations enable strictness analysis. I was actually being an annoying purist. f is strict means f _|_ = _|_, so strictness is a semantic idea, not an operational one.

Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-03 Thread David Menendez
On Mon, Nov 3, 2008 at 5:39 PM, Henning Thielemann [EMAIL PROTECTED] wrote: On Mon, 3 Nov 2008, Luke Palmer wrote: On Mon, Nov 3, 2008 at 2:54 PM, Don Stewart [EMAIL PROTECTED] wrote: Optimisations enable strictness analysis. I was actually being an annoying purist. f is strict means f

Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-03 Thread Matthew Brecknell
Don Stewart: Optimisations enable strictness analysis. Luke Palmer: I was actually being an annoying purist. f is strict means f _|_ = _|_, so strictness is a semantic idea, not an operational one. Optimizations can change operation, but must preserve semantics. Henning Thielemann: Maybe I

Re: [Haskell-cafe] Problems with strictness analysis?

2008-11-03 Thread wren ng thornton
Patai Gergely wrote: Hi everyone, I was experimenting with simple accumulator functions, and found that an apparently tail recursive function can easily fill the stack. Playing around with ghc and jhc gave consistently unpleasant results. Look at this program: %%% -- ghc: no, ghc -O3: