Fix Trac #3437: strictness of specialised functions
authorsimonpj@microsoft.com <unknown>
Fri, 21 Aug 2009 09:52:51 +0000 (09:52 +0000)
committersimonpj@microsoft.com <unknown>
Fri, 21 Aug 2009 09:52:51 +0000 (09:52 +0000)
commitef5376d5fa26d37c828a9c88dde3cf6f92f273ab
treed74e9f77b974a3b75f18cd930d94c1e4459c383f
parentf7df28a48a9d2901d9e27e0e9970b3f692bc9b3f
Fix Trac #3437: strictness of specialised functions

'lilac' helpful pin-pointed a space leak that was due to a specialised
function being insufficiently strict.  Here's the new comment in SpecConstr:

Note [Transfer strictness]
~~~~~~~~~~~~~~~~~~~~~~~~~~
We must transfer strictness information from the original function to
the specialised one.  Suppose, for example

  f has strictness     SS
        and a RULE     f (a:as) b = f_spec a as b

Now we want f_spec to have strictess  LLS, otherwise we'll use call-by-need
when calling f_spec instead of call-by-value.  And that can result in
unbounded worsening in space (cf the classic foldl vs foldl')

See Trac #3437 for a good example.

The function calcSpecStrictness performs the calculation.
compiler/specialise/SpecConstr.lhs