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