Generalising the demand analysis to sum types

Simon Peyton Jones simonpj at microsoft.com
Fri Mar 4 10:21:09 UTC 2016


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

I'm not sure you really need that. You could instead say that USum xs implies at least UHead on all the other tags not mentioned in xs.

Simon

|  -----Original Message-----
|  From: José Manuel Calderón Trilla [mailto:jmct at jmct.cc]
|  Sent: 03 March 2016 04:53
|  To: Simon Peyton Jones <simonpj at microsoft.com>
|  Cc: Joachim Breitner <mail at joachim-breitner.de>; Ömer Sinan Ağacan
|  <omeragacan at gmail.com>; ghc-devs at haskell.org
|  Subject: Re: Generalising the demand analysis to sum types
|  
|  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