[Haskell-cafe] extending bang proposal Re: strict Haskell dialect

Brian Hulley brianh at metamilk.com
Mon Feb 6 13:33:38 EST 2006


Bulat Ziganshin wrote:
> yes, i remember this SPJ's question :)  "[!a]" means that list
> elements are strict, it's the same as defining new list type with
> strict elements and using it here. "![a]" means "strict list", it is
> the same as defining list with "next" field strict:
>
> data List1 a = Nil1 | List1 !a (List1 a)
> data List2 a = Nil2 | List2 a !(List2 a)
> data List3 a = Nil3 | List3 !a !(List3 a)

Clean allows (AFAIK) several distinctions to be made:

1) ![a] means that the list of a's is a strict argument, just like writing 
!b

2) [!a] means that the list is head strict (List1 a)

3) [a!] means that the list is tail strict (List2 a)

4) [!a!] means that the list is head and tail strict (List3 a)

5) ![!a!] means that the head-and-tail-strict-list-argument is strict!!!

I think also (though I'm not entirely sure) that these distinctions are 
generalized for other data types by talking about element strictness and 
spine strictness.

One motivation seems to be that in the absence of whole program 
optimization, the strictness annotations on a function's type can allow the 
compiler to avoid creating thunks at the call site for cross-module calls 
whereas using seq in the function body itself means that the thunk still has 
to be created at the call site because the compiler can't possibly know that 
it's going to be immediately evaluated by seq.

Regards, Brian. 



More information about the Haskell-Cafe mailing list