Strict Haskell debate

Andy Gill andy at galois.com
Fri Feb 17 18:14:31 EST 2006


I'd like to see a way of enforcing return strictness, that is where you
have confidence that what a function is returning is fully evaluated.

Imagine a function hstrict;

  	hstrict :: a -> a

you can define hseq with this.

hseq :: a -> b -> b
hseq a b = hstrict a `seq` b

and $!!.

($!!) :: (a -> b) -> a -> b
a $!! b = a $! (hstrict b)

With hstrict you can write functions in the style.

fun f a b c = hstrict $ ....
   where
	...
	...

and also

fun f a b c = hstruct $ bla { abc = def , cfg = tts , ... }

We know that strictness plays no part in the returned value
after the function is finished evaluating, which is a Useful Property.

What I'd like is a efficient hstrict, that does not re-evaluate anything
that has already been hstrict-ified. In the same way as we evaluate
an object, we could strictify an object using a similar (low-level)  
mechanism.
So the cost of calling hstrict would be amortized away to almost  
nothing.

How much work would this be to add hstrict GHC? A extra bit in the
runtime representation? Could we use the speculation mechanism to do it?

Andy Gill





More information about the Haskell-prime mailing list