strictness of interpreted haskell implementations

Geraint Jones Geraint.Jones at wolfson.ox.ac.uk
Mon May 4 19:43:15 EDT 2009


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?)


More information about the Glasgow-haskell-users mailing list