RE: Strictness annotations on type parameters

2005-12-07 Thread Simon Peyton-Jones
It's not at all easy in general. Suppose we have f :: [!a] - [a] f xs = xs Does f run down the list, behind the scenes, evaluating each element? That could be expensive. Would it make any difference if we wrote f :: [!a] - [a], or f :: [a] - [!a]? Or does the type mean that f

Re: Strictness annotations on type parameters

2005-12-07 Thread Ralf Hinze
It's hard to avoid the feeling that one ought to be able to say something useful about strictness in the types but it's swampy territory, and hard to get right. Fortunately, it's easy to dry up the `swampy territory'. The type `Contract' below models strictness requirements. The function

Re: Strictness annotations on type parameters

2005-12-07 Thread Mario Blazevic
It's not at all easy in general. Suppose we have f :: [!a] - [a] f xs = xs Does f run down the list, behind the scenes, evaluating each element? No, because what [!a] means is List !a = ([] | !a : List !a). It does not mean ([] | !(!a : List !a)). Since the Cons thunks

Re: Strictness annotations on type parameters

2005-12-06 Thread Duncan Coutts
On Tue, 2005-12-06 at 16:05 -0500, Mario Blazevic wrote: No container data type can be annotated as strict. That means I have to pepper my code with explicit evaluations to HNF before every writeIORef (reference label): newState `seq` writeIORef (reference label) newState Or it can be