Generalising the demand analysis to sum types

José Manuel Calderón Trilla jmct at jmct.cc
Thu Mar 3 04:53:11 UTC 2016


Hello again,

On Tue, Mar 1, 2016 at 11:56 AM, Simon Peyton Jones
<simonpj at microsoft.com> wrote:
>
> Don't forget AbsDmd too!
>

Yes, we're working on this too. Currently we're doing something
analogous to what we're doing with StrDmd:

data UseDmd
  = UCall Count UseDmd
  | UProd [ArgUse]
  | USum [(Tag, UseDmd)]
  | UHead
  | Used

The big question deals with how to 'insert' a usage demand on an
alternative of a case into a usage demand on the entire sum. The
current thought is that you collect the usage demands on the fields of
the constructor for the alternative you're analysing (let's say it's
tag 1) and insert that into a USum where the usage demands on all the
other constructors (all the tags except 1) is UHead. The rational
behind using UHead is that the constructor itself is demanded at UHead
by the case expression. Once you have one of these for every
alternative, you lub them together appropriately, so anywhere you
actually used a field would be represented in the final demand on the
sum since UHead `lubUse` u = u


> Do start a wiki page to explain all this.
>

Definitely.

Cheers,

Jose


More information about the ghc-devs mailing list