Re[2]: strictness of interpreted haskell implementations
Hello Neil, Monday, May 18, 2009, 8:14:56 PM, you wrote: >> As an ex teaching assistant my recommendation is "Use ghci!". > I helped to teach using WinHugs, which was quite nice. Auto reload > cuts out one very frequent source of problems. i think we should fill a ticket against it. auto-save in editor + auto-reload make really incredible environment -- Best regards, Bulatmailto:bulat.zigans...@gmail.com ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: strictness of interpreted haskell implementations
Hi >> data S = S { a :: Int, b :: ! Int } >> >> Main> a (S { a = 0, b = 1 }) >> 0 >> Main> a (S { a = 0, b = undefined }) >> 0 >> >> Ho hum. Is this a "known difference"? I've submitted a bug: http://hackage.haskell.org/trac/hugs/ticket/92 > As an ex teaching assistant my recommendation is "Use ghci!". I helped to teach using WinHugs, which was quite nice. Auto reload cuts out one very frequent source of problems. Thanks Neil ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: strictness of interpreted haskell implementations
On Tue, 2009-05-05 at 00:43 +0100, Geraint Jones wrote: > Sorry to revive a year-old thread, but... > > On Fri, 25 Apr 2008 at 20:17:53 +0100 Duncan Coutts wrote: > > On Fri, 2008-04-25 at 09:08 -0700, Don Stewart wrote: > > > Geraint.Jones: > > > > Are there well-known differences in the implementations of Haskell in > > > > ghci and hugs? I've got some moderately intricate code (simulations > > > > of pipelined processors) that behave differently - apparently because > > > > ghci Haskell is stricter than hugs Haskell, and I cannot find any > > > > obviously relevant claims about strictness in the documentation. > > > > I think they should give the same answer. It sounds like a bug in one > > implementation or the other. > > > > > Hugs does no optimisations, while GHC does a truckload, including > > > strictness analysis. Some of these optimisations prevent space leaks. > > > > Though none should change the static semantics. > > > > Post the code. Even if you don't have time to track down the difference, > > someone might. > > At the time I was reluctant to impose all the code on anyone and I found > it hard to cut the example down to a manageable size. I've just got it > down to a one-liner: it's the implementation of what I think ought to be > strict fields in records: > > data S = S { a :: Int, b :: ! Int } > > I think ghci is correct: > > *Main> a (S { a = 0, b = 1 }) > 0 > *Main> a (S { a = 0, b = undefined }) > *** Exception: Prelude.undefined > > and that hugs had been concealing a bug in my program by not demanding > one of the fields of S when it ought to: > > Main> a (S { a = 0, b = 1 }) > 0 > Main> a (S { a = 0, b = undefined }) > 0 > > Ho hum. Is this a "known difference"? It's certainly a bug. I suspect it is not well known. It's not documented at http://cvs.haskell.org/Hugs/pages/users_guide/haskell98.html#BUGS-HASKELL98 Also, if we instead define: data S' = S' Int !Int a' (S' x _) = x b' (S' _ x) = x Then: Main> a' (S' 0 undefined) Program error: Prelude.undefined Which is clearly inconsistent. There's something wrong in hugs with the strictness annotations on data defined using the record syntax. > (What makes you think I'm teaching the same course again this year?) :-) As an ex teaching assistant my recommendation is "Use ghci!". Duncan ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: strictness of interpreted haskell implementations
Sorry to revive a year-old thread, but... On Fri, 25 Apr 2008 at 20:17:53 +0100 Duncan Coutts wrote: > On Fri, 2008-04-25 at 09:08 -0700, Don Stewart wrote: > > Geraint.Jones: > > > Are there well-known differences in the implementations of Haskell in > > > ghci and hugs? I've got some moderately intricate code (simulations > > > of pipelined processors) that behave differently - apparently because > > > ghci Haskell is stricter than hugs Haskell, and I cannot find any > > > obviously relevant claims about strictness in the documentation. > > I think they should give the same answer. It sounds like a bug in one > implementation or the other. > > > Hugs does no optimisations, while GHC does a truckload, including > > strictness analysis. Some of these optimisations prevent space leaks. > > Though none should change the static semantics. > > Post the code. Even if you don't have time to track down the difference, > someone might. At the time I was reluctant to impose all the code on anyone and I found it hard to cut the example down to a manageable size. I've just got it down to a one-liner: it's the implementation of what I think ought to be strict fields in records: data S = S { a :: Int, b :: ! Int } I think ghci is correct: *Main> a (S { a = 0, b = 1 }) 0 *Main> a (S { a = 0, b = undefined }) *** Exception: Prelude.undefined and that hugs had been concealing a bug in my program by not demanding one of the fields of S when it ought to: Main> a (S { a = 0, b = 1 }) 0 Main> a (S { a = 0, b = undefined }) 0 Ho hum. Is this a "known difference"? (What makes you think I'm teaching the same course again this year?) ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: strictness of interpreted haskell implementations
On Fri, Apr 25, 2008 at 9:17 PM, Duncan Coutts <[EMAIL PROTECTED]> wrote: > > On Fri, 2008-04-25 at 09:08 -0700, Don Stewart wrote: > > Geraint.Jones: > > > Are there well-known differences in the implementations of Haskell in > > > ghci and hugs? I've got some moderately intricate code (simulations > > > of pipelined processors) that behave differently - apparently because > > > ghci Haskell is stricter than hugs Haskell, and I cannot find any > > > obviously relevant claims about strictness in the documentation. > > I think they should give the same answer. It sounds like a bug in one > implementation or the other. > I suspect this might be a library thing. If ghc and hugs uses different versions of the library and some function had its strictness property changed then that might account for the discrepancy. > > Hugs does no optimisations, while GHC does a truckload, including > > strictness analysis. Some of these optimisations prevent space leaks. > > Though none should change the static semantics. > That was my initial reaction as well, but then I recalled that some of ghc's optimizations actually changes the strictness behavior. The foldr/build transformation for instance can actually change the strictness of a function such that you can actually observe it. So we can't rule out that ghc is doing something it shouldn't be doing. > Post the code. Even if you don't have time to track down the difference, > someone might. > Yep, without the code we're just fumbling in the dark. Cheers, Josef ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: strictness of interpreted haskell implementations
On Fri, 2008-04-25 at 09:08 -0700, Don Stewart wrote: > Geraint.Jones: > > Are there well-known differences in the implementations of Haskell in > > ghci and hugs? I've got some moderately intricate code (simulations > > of pipelined processors) that behave differently - apparently because > > ghci Haskell is stricter than hugs Haskell, and I cannot find any > > obviously relevant claims about strictness in the documentation. I think they should give the same answer. It sounds like a bug in one implementation or the other. > Hugs does no optimisations, while GHC does a truckload, including > strictness analysis. Some of these optimisations prevent space leaks. Though none should change the static semantics. Post the code. Even if you don't have time to track down the difference, someone might. Duncan ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: strictness of interpreted haskell implementations
Geraint.Jones: > Are there well-known differences in the implementations of Haskell in > ghci and hugs? I've got some moderately intricate code (simulations > of pipelined processors) that behave differently - apparently because > ghci Haskell is stricter than hugs Haskell, and I cannot find any > obviously relevant claims about strictness in the documentation. Hugs does no optimisations, while GHC does a truckload, including strictness analysis. Some of these optimisations prevent space leaks. You might want to also check with ghc -Onot , ghc -O2 (esp. if performance matters). -- Don ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
strictness of interpreted haskell implementations
Are there well-known differences in the implementations of Haskell in ghci and hugs? I've got some moderately intricate code (simulations of pipelined processors) that behave differently - apparently because ghci Haskell is stricter than hugs Haskell, and I cannot find any obviously relevant claims about strictness in the documentation. ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users