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

Ronny Wichers Schreur ronny at cs.ru.nl
Mon Feb 6 16:25:05 EST 2006


On Feb 6, 2006, at 19:33, Brian Hulley wrote:

> 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!!!

Right. I think it's worth stressing that the four possible list types
are all different as far as type checking is concerned. There's special
list syntax however to denote lists that are overloaded in the list
type.

At run time the different list types share the same nil and cons
constructors. This means that conversions between list types
are often cheap. I have a small library that does this, with the
following costs (monospaced table):

\to
   \    [  ] [! ] [ !] [!!]
frm\
[  ]     0    c    e!  !e!

[! ]     0    0    e!   e!

[ !]     0    c    0   !e

[!!]     0    0    0    0

0  = doesn't traverse list
e  = traverses list (evaluating elements (!e), spine (e!), or both (! 
e!))
c  = copies list (lazily, evaluating elements)

> 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.

No, there's no such generalisation.


Cheers,

Ronny Wichers Schreur


More information about the Haskell-Cafe mailing list