Wildcard refactoring

Simon Peyton Jones simonpj at microsoft.com
Tue Dec 1 13:34:54 UTC 2015


OK, I think it’s time to commit my branch

            wip/spj-wildcard-refactor

Ben: could you commit it as a single large patch (ignore the branch history).  A commit message appears below.  There is a corresponding patch for haddock, with same branch name in the haddock repo.


Could you also open a ticket for the performance regression on perf/compiler/T3064?  I don’t want to forget it, but it’s past time to commit such a big, invasive patch.

There are two other tests failing for me, which appear to do with the version number for the containers sub-module.  I think I have failed to get the other submodules (other than haddock) right.  I was NOT intending to change them, so just use origin/master for them.


Everyone: take a look at the commit message below.  I’ve been working on this for far too long, in spare moments.  Richard, I’m sorry that it’ll be disruptive to your changes, but in a good way I hope.

Simon



This patch began as a modest refactoring of HsType and friends, to

clarify and tidy up exactly where quantification takes place in

types. Although initially driven by making the implementation of

wildcards more tidy (and fixing a number of bugs), I gradually got

drawn into a pretty big process, which I've been doing on and off for

quite a long time.



There is one compiler performance regression as a result of all

this, in perf/compiler/T3064.  I still need to look into that.



* The principal driving change is described in Note [HsType binders]

  in HsType.  Well worth reading!



* Those data type changes drive almost

  everything else.  In particular we now statically know where

       (a) implicit quantification only (LHsSigType),

           e.g. in instance declaratios and SPECIALISE signatures

       (b) implicit quantification and wildcards (LHsSigWcType)

           can appear, e.g. in function type signatures



* As part of this change, HsForAllTy is (a) simplified (no wildcards)

  and (b) split into HsForAllTy and HsQualTy.  The two contructors

  appear when and only when the correponding user-level construct

  appears.  Again see Note [HsType binders].



  HsExplicitFlag disappears altogether.



* Other simplifications

     - ExprWithTySig no longer needs an ExprWithTySigOut variant

     - TypeSig no longer needs a PostRn name [name] field

       for wildcards

     - PatSynSig records a LHsSigType rather than the decomposed pieces

     - The mysterious 'GenericSig' is now 'ClassOpSig'



* Renamed LHsTyVarBndrs to LHsQTyVars



* There are some uninteresting knock-on changes in Haddock,

  because of the HsSyn changes





I also did a bunch of loosely-related changes:



* We already had type synonyms CoercionN/CoercionR for nominal and

  representational coercions.  I've added similar treatment for

      TcCoercionN/TcCoercionR

      mkWpCastN/mkWpCastN

  All just type synonyms but jolly useful.



* I record-ised ForeignImport and ForeignExport



* I improved the (poor) fix to Trac #10896, by making

  TcTyClsDecls.checkValidTyCl recover from errors, but adding a

  harmless, abstract TyCon to the envt if so.



* I did some significant refactoring in RnEnv.lookupSubBndrOcc,

  for reasons that I have (embarrassingly) now totally forgotten.

  It had to do with something to do with import and export




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20151201/bc1d5f09/attachment-0001.html>


More information about the ghc-devs mailing list