1. 07 Mar, 2009 1 commit
  2. 06 Mar, 2009 1 commit
  3. 02 Jan, 2009 1 commit
    • simonpj@microsoft.com's avatar
      Make record selectors into ordinary functions · 9ffadf21
      simonpj@microsoft.com authored
      This biggish patch addresses Trac #2670.  The main effect is to make
      record selectors into ordinary functions, whose unfoldings appear in
      interface files, in contrast to their previous existence as magic
      "implicit Ids".  This means that the usual machinery of optimisation,
      analysis, and inlining applies to them, which was failing before when
      the selector was somewhat complicated.  (Which it can be when
      strictness annotations, unboxing annotations, and GADTs are involved.)
      The change involves the following points
      * Changes in Var.lhs to the representation of Var.  Now a LocalId can
        have an IdDetails as well as a GlobalId.  In particular, the
        information that an Id is a record selector is kept in the
        IdDetails.  While compiling the current module, the record selector
        *must* be a LocalId, so that it participates properly in compilation
        (free variables etc).
        This led me to change the (hidden) representation of Var, so that there
        is now only one constructor for Id, not two.
      * The IdDetails is persisted into interface files, so that an
        importing module can see which Ids are records selectors.
      * In TcTyClDecls, we generate the record-selector bindings in renamed,
        but not typechecked form.  In this way, we can get the typechecker
        to add all the types and so on, which is jolly helpful especially
        when GADTs or type families are involved.  Just like derived
        instance declarations.
        This is the big new chunk of 180 lines of code (much of which is
        commentary).  A call to the same function, mkAuxBinds, is needed in
        TcInstDcls for associated types.
      * The typechecker therefore has to pin the correct IdDetails on to 
        the record selector, when it typechecks it.  There was a neat way
        to do this, by adding a new sort of signature to HsBinds.Sig, namely
        IdSig.  This contains an Id (with the correct Name, Type, and IdDetails);
        the type checker uses it as the binder for the final binding.  This
        worked out rather easily.
      * Record selectors are no longer "implicit ids", which entails changes to
        (These three functions must agree.)
      * MkId.mkRecordSelectorId is deleted entirely, some 300+ lines (incl
        comments) of very error prone code.  Happy days.
      * A TyCon no longer contains the list of record selectors: 
        algTcSelIds is gone
      The renamer is unaffected, including the way that import and export of
      record selectors is handled.
      Other small things
      * IfaceSyn.ifaceDeclSubBndrs had a fragile test for whether a data
        constructor had a wrapper.  I've replaced that with an explicit flag
        in the interface file. More robust I hope.
      * I renamed isIdVar to isId, which touched a few otherwise-unrelated files.
  4. 20 Sep, 2008 1 commit
    • simonpj@microsoft.com's avatar
      Tidy up the treatment of dead binders · 7e8cba32
      simonpj@microsoft.com authored
      This patch does a lot of tidying up of the way that dead variables are
      handled in Core.  Just the sort of thing to do on an aeroplane.
      * The tricky "binder-swap" optimisation is moved from the Simplifier
        to the Occurrence Analyser.  See Note [Binder swap] in OccurAnal.
        This is really a nice change.  It should reduce the number of
        simplifier iteratoins (slightly perhaps).  And it means that
        we can be much less pessimistic about zapping occurrence info
        on binders in a case expression.  
      * For example:
      	case x of y { (a,b) -> e }
        Previously, each time around, even if y,a,b were all dead, the
        Simplifier would pessimistically zap their OccInfo, so that we
        can't see they are dead any more.  As a result virtually no 
        case expression ended up with dead binders.  This wasn't Bad
        in itself, but it always felt wrong.
      * I added a check to CoreLint to check that a dead binder really
        isn't used.  That showed up a couple of bugs in CSE. (Only in
        this sense -- they didn't really matter.)
      * I've changed the PprCore printer to print "_" for a dead variable.
        (Use -dppr-debug to see it again.)  This reduces clutter quite a
        bit, and of course it's much more useful with the above change.
      * Another benefit of the binder-swap change is that I could get rid of
        the Simplifier hack (working, but hacky) in which the InScopeSet was
        used to map a variable to a *different* variable. That allowed me
        to remove VarEnv.modifyInScopeSet, and to simplify lookupInScopeSet
        so that it doesn't look for a fixpoint.  This fixes no bugs, but 
        is a useful cleanup.
      * Roman pointed out that Id.mkWildId is jolly dangerous, because
        of its fixed unique.  So I've 
           - localied it to MkCore, where it is private (not exported)
           - renamed it to 'mkWildBinder' to stress that you should only
             use it at binding sites, unless you really know what you are
           - provided a function MkCore.mkWildCase that emodies the most
             common use of mkWildId, and use that elsewhere
         So things are much better
      * A knock-on change is that I found a common pattern of localising
        a potentially global Id, and made a function for it: Id.localiseId
  5. 16 Sep, 2008 1 commit
  6. 07 Aug, 2008 1 commit
  7. 31 Jul, 2008 2 commits
  8. 12 Apr, 2008 1 commit
  9. 26 Jan, 2008 1 commit
  10. 06 Dec, 2007 1 commit
  11. 19 Nov, 2007 1 commit
  12. 18 Nov, 2007 1 commit
  13. 17 Nov, 2007 1 commit
  14. 16 Nov, 2007 3 commits
  15. 04 Sep, 2007 1 commit
  16. 03 Sep, 2007 1 commit
  17. 01 Sep, 2007 1 commit
  18. 31 Aug, 2007 3 commits
  19. 30 Aug, 2007 3 commits
  20. 24 Aug, 2007 11 commits
  21. 23 Aug, 2007 3 commits