Strictness in data declaration not matched in assembler?

Roman Leshchinskiy rl at
Thu Oct 16 07:03:05 EDT 2008

On 16/10/2008, at 21:34, Simon Peyton-Jones wrote:

> For strict *constructors*, on the other hand, we *do* guarantee to  
> evaluate the argument before building the constructor.  We generate  
> a wrapper thus
>        wC = \ab. case a of { a' -> C a' b }
> (Remember 'case' always evaluates in Core.)  So for strict  
> constructors we could take advantage of the known evaluated-ness of  
> the result to avoid the test.
> BUT people who care probably UNPACK their strict fields too, which  
> is even better.  The time you can't do that is for sum types
>        data T = MkT ![Int]

You also can't do it for polymorphic components. I've used code like:

   data T a = MkT !a

   foo :: T (a,b) -> a
   foo (MkT (x,y)) = x

Here, unpacking doesn't work but foo could still access the components  
of the pair directly.


More information about the Glasgow-haskell-users mailing list