1. 23 Jun, 2016 3 commits
    • niteria's avatar
      Provide Uniquable version of SCC · 35d1564c
      niteria authored
      We want to remove the `Ord Unique` instance because there's
      no way to implement it in deterministic way and it's too
      easy to use by accident.
      
      We sometimes compute SCC for datatypes whose Ord instance
      is implemented in terms of Unique. The Ord constraint on
      SCC is just an artifact of some internal data structures.
      We can have an alternative implementation with a data
      structure that uses Uniquable instead.
      
      This does exactly that and I'm pleased that I didn't have
      to introduce any duplication to do that.
      
      Test Plan:
      ./validate
      I looked at performance tests and it's a tiny bit better.
      
      Reviewers: bgamari, simonmar, ezyang, austin, goldfire
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2359
      
      GHC Trac Issues: #4012
      35d1564c
    • Simon Peyton Jones's avatar
      Narrow the warning for simplifiable constraints · 643706e4
      Simon Peyton Jones authored
      In Trac #11948 I added the warning
          -Wsimplifiable-class-constraints
      which warns if the class constraints in a type signature are
      simplifiable.
      
      But in fact the fragility it warns about only happens with
      NoMonoLocalBinds, so this patch switches off the warning if
      you have MonoLocalBinds (and suggests using it in the error
      message).
      
      See Note [Simplifiable given constraints] in TcValidity.
      643706e4
    • Simon Peyton Jones's avatar
      Give lookupGRE_Name a better API · 3e0af469
      Simon Peyton Jones authored
      lookupGRE_Name should return either zero or one GREs, never
      several. This is a consequence of INVARIANT 1 on GlobalRdrEnv.
      
      So it's better if it returns a Maybe; the panic on multiple results
      is put in one place, instead of being scattered or ignored.
      
      Just refactoring, no change in behaviour
      3e0af469
  2. 22 Jun, 2016 9 commits
    • Simon Peyton Jones's avatar
      Expand given superclasses more eagerly · ce97b729
      Simon Peyton Jones authored
      This patch fixes Trac #12175, another delicate corner case of
      Note [Instance and Given overlap] in TcInteract.
      
      In #12175 we were not expanding given superclasses eagerly
      enough. It was easy to fix, and is actually rather neater than
      before.
      
      See Note [Eagerly expand given superclasses] in TcCanonical.
      The main change is to move the eager expansion of given superclasses
      to canClassNC.
      ce97b729
    • Simon Peyton Jones's avatar
      Remove unused arg to tcSuperClasses · a1b33596
      Simon Peyton Jones authored
      We don't need the FamInstEnvs argument any more.
      Just a tiny refactor.
      a1b33596
    • Simon Peyton Jones's avatar
      Improve error message in deriving( Functor ) · cc92a446
      Simon Peyton Jones authored
      Fixes Trac #12163.  Pretty simple.
      cc92a446
    • Simon Peyton Jones's avatar
      Comments only · 7e7aeab2
      Simon Peyton Jones authored
      7e7aeab2
    • niteria's avatar
      Make the Ord Module independent of Unique order (2nd try) · 348f2dbb
      niteria authored
      The `Ord Module` instance currently uses `Unique`s for comparison.
      We don't want to use the `Unique` order because it can introduce
      nondeterminism.
      This switches `Ord ModuleName` and `Ord UnitId` to use lexicographic
      ordering making `Ord Module` deterministic transitively.
      
      I've run `nofib` and it doesn't make a measurable difference.
      
      See also Note [ModuleEnv determinism and performance].
      
      This fixes #12191 - the regression, that the previous version of this
      patch had.
      
      Test Plan:
      ./validate
      run nofib: P112
      
      Reviewers: simonmar, bgamari, austin
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2354
      
      GHC Trac Issues: #4012, #12191
      348f2dbb
    • Gabor Greif's avatar
      More typos in comments [skip ci] · 61995883
      Gabor Greif authored
      61995883
    • Simon Marlow's avatar
      9d62d09a
    • Simon Marlow's avatar
      Fix build breakage due to rebase · c0583a9e
      Simon Marlow authored
      c0583a9e
    • Simon Marlow's avatar
      Second attempt to fix sizeExpr · a47b62cb
      Simon Marlow authored
      Summary:
      Background:
      * sizeExpr was calculating expressions like ((e `cast` T) x) wrongly
      * Fixing it caused regressions in compile performance, and one nofib
        program (k-nucleotide)
      
      I managed to fix the source of the compiler regressions.  I think it was
      due to traceTc not being inlined, which I fixed in a more robust way by
      putting an export list on TcRnMonad.
      
      The k-nucleotide regression is more difficult.  I don't think anything
      is actually going wrong, but this program has been highly tuned and is
      quite sensitive to changing in inlining behaviour.  I managed to recover
      most of the performance by manual lambda-lifting which makes it a bit
      less fragile, but the end result was a bit slower.  I don't think this
      is disastrous, the program is pretty horrible to begin with and we could
      probably make a faster one by starting from scratch.
      
      Test Plan: validate, nofib
      
      Reviewers: simonpj, bgamari, niteria, austin, erikd
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2338
      
      GHC Trac Issues: #11564
      a47b62cb
  3. 21 Jun, 2016 3 commits
    • niteria's avatar
      Make checkFamInstConsistency less expensive · 12306294
      niteria authored
      Doing canonicalization on every comparison turned
      out to be very expensive.
      
      Caching the canonicalization through the smart `modulePair` constructor
      gives `8%` reduction in allocations on `haddock.compiler` and
      `8.5%` reduction in allocations on `haddock.Cabal`.
      Possibly other things as well, but it's really visible in Haddock.
      
      Test Plan: ./validate
      
      Reviewers: jstolarek, simonpj, austin, simonmar, bgamari
      
      Reviewed By: simonpj, simonmar
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2350
      
      GHC Trac Issues: #12191
      12306294
    • Simon Peyton Jones's avatar
      Delete commented-out code · 97a50f82
      Simon Peyton Jones authored
      Richard: in a previous commit I combined the two case for
      
         decideQuantification
      
      This commit just deletes the old code. I'm afraid it'll leave you
      with a merge conflict though, with your stuff on generalisation.
      97a50f82
    • Gabor Greif's avatar
      Typos in comments · 7301404d
      Gabor Greif authored
      7301404d
  4. 18 Jun, 2016 1 commit
    • Ryan Scott's avatar
      Refactor derived Generic instances to reduce allocations · 9649fc0a
      Ryan Scott authored
      Previously, derived implementations of `to`/`from` in `Generic`
      instances were wastefully putting extra `M1`s in every case, which led
      to an O(n) increase in the number of coercions, resulting in a slowdown
      during the typechecker phase.
      
      This factors out the common `M1` in every case of a `to`/`from`
      definition so that the typechecker has far fewer coercions to deal with.
      For a datatype with 300 constructors, this change has been observed to
      save almost 3 seconds of compilation time.
      
      This is one step towards coming up with a solution for #5642.
      
      Test Plan: ./validate
      
      Reviewers: hvr, austin, simonpj, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: basvandijk, carter, thomie, osa1
      
      Differential Revision: https://phabricator.haskell.org/D2304
      
      GHC Trac Issues: #5642
      9649fc0a
  5. 15 Jun, 2016 2 commits
    • Simon Peyton Jones's avatar
      Major patch to introduce TyConBinder · e368f326
      Simon Peyton Jones authored
      Before this patch, following the TypeInType innovations,
      each TyCon had two lists:
        - tyConBinders :: [TyBinder]
        - tyConTyVars  :: [TyVar]
      
      They were in 1-1 correspondence and contained
      overlapping information.  More broadly, there were many
      places where we had to pass around this pair of lists,
      instead of a single list.
      
      This commit tidies all that up, by having just one list of
      binders in a TyCon:
      
        - tyConBinders :: [TyConBinder]
      
      The new data types look like this:
      
        Var.hs:
           data TyVarBndr tyvar vis = TvBndr tyvar vis
           data VisibilityFlag = Visible | Specified | Invisible
           type TyVarBinder = TyVarBndr TyVar VisibilityFlag
      
        TyCon.hs:
           type TyConBinder = TyVarBndr TyVar TyConBndrVis
      
           data TyConBndrVis
             = NamedTCB VisibilityFlag
             | AnonTCB
      
        TyCoRep.hs:
           data TyBinder
             = Named TyVarBinder
             | Anon Type
      
      Note that Var.TyVarBdr has moved from TyCoRep and has been
      made polymorphic in the tyvar and visiblity fields:
      
           type TyVarBinder = TyVarBndr TyVar VisibilityFlag
              -- Used in ForAllTy
           type TyConBinder = TyVarBndr TyVar TyConBndrVis
              -- Used in TyCon
      
           type IfaceForAllBndr  = TyVarBndr IfaceTvBndr VisibilityFlag
           type IfaceTyConBinder = TyVarBndr IfaceTvBndr TyConBndrVis
               -- Ditto, in interface files
      
      There are a zillion knock-on changes, but everything
      arises from these types.  It was a bit fiddly to get the
      module loops to work out right!
      
      Some smaller points
      ~~~~~~~~~~~~~~~~~~~
      * Nice new functions
          TysPrim.mkTemplateKiTyVars
          TysPrim.mkTemplateTyConBinders
        which help you make the tyvar binders for dependently-typed
        TyCons.  See comments with their definition.
      
      * The change showed up a bug in TcGenGenerics.tc_mkRepTy, where the code
        was making an assumption about the order of the kind variables in the
        kind of GHC.Generics.(:.:).  I fixed this; see TcGenGenerics.mkComp.
      e368f326
    • Simon Peyton Jones's avatar
      Re-add FunTy (big patch) · 77bb0927
      Simon Peyton Jones authored
      With TypeInType Richard combined ForAllTy and FunTy, but that was often
      awkward, and yielded little benefit becuase in practice the two were
      always treated separately.  This patch re-introduces FunTy.  Specfically
      
      * New type
          data TyVarBinder = TvBndr TyVar VisibilityFlag
        This /always/ has a TyVar it.  In many places that's just what
        what we want, so there are /lots/ of TyBinder -> TyVarBinder changes
      
      * TyBinder still exists:
          data TyBinder = Named TyVarBinder | Anon Type
      
      * data Type = ForAllTy TyVarBinder Type
                  | FunTy Type Type
                  |  ....
      
      There are a LOT of knock-on changes, but they are all routine.
      
      The Haddock submodule needs to be updated too
      77bb0927
  6. 14 Jun, 2016 2 commits
  7. 13 Jun, 2016 8 commits
    • Simon Peyton Jones's avatar
      Remove some traceTc calls · 8104f7c6
      Simon Peyton Jones authored
      During the kind-checking "knot" we have to be careful not
      to print too eagerly.
      8104f7c6
    • Simon Peyton Jones's avatar
      Fix the in-scope set for extendTvSubstWithClone · 15fc5281
      Simon Peyton Jones authored
      We'd forgotten the variables free in the kind.
      
      Ditto extendCvSubstWithClone
      15fc5281
    • Simon Peyton Jones's avatar
      Beef up mkNakedCastTy · 1f661281
      Simon Peyton Jones authored
      By spotting Refl coercions we can avoid building an awful
      lot of CastTys.  Simple and effective.
      1f661281
    • Simon Peyton Jones's avatar
      Move the constraint-kind validity check · 35c9de7c
      Simon Peyton Jones authored
      For type synonyms, we need to check that if the RHS has
      kind Constraint, then we have -XConstraintKinds.  For
      some reason this was done in checkValidType, but it makes
      more sense to do it in checkValidTyCon.
      
      I can't remember quite why I made this change; maybe it fixes
      a Trac ticket, but if so I forget which.  But it's a modest
      improvement anyway.
      35c9de7c
    • Simon Peyton Jones's avatar
      Get in-scope set right in top_instantiate · 7afb7adf
      Simon Peyton Jones authored
      ...thereby being able to replace substThetaUnchecked
      with substTheta
      7afb7adf
    • Simon Peyton Jones's avatar
      Tidy up zonkQuantifiedTyVar · c28dde37
      Simon Peyton Jones authored
      I managed to eliminate the strange zonkQuantifiedTyVarOrType,
      which is no longer used.
      c28dde37
    • Simon Peyton Jones's avatar
      Improve typechecking of let-bindings · 15b9bf4b
      Simon Peyton Jones authored
      This major commit was initially triggered by #11339, but it spiraled
      into a major review of the way in which type signatures for bindings
      are handled, especially partial type signatures.  On the way I fixed a
      number of other bugs, namely
         #12069
         #12033
         #11700
         #11339
         #11670
      
      The main change is that I completely reorganised the way in which type
      signatures in bindings are handled. The new story is in TcSigs
      Note [Overview of type signatures].  Some specific:
      
      * Changes in the data types for signatures in TcRnTypes:
        TcIdSigInfo and new TcIdSigInst
      
      * New module TcSigs deals with typechecking type signatures
        and pragmas. It contains code mostly moved from TcBinds,
        which is already too big
      
      * HsTypes: I swapped the nesting of HsWildCardBndrs
        and HsImplicitBndsrs, so that the wildcards are on the
        oustide not the insidde in a LHsSigWcType.  This is just
        a matter of convenient, nothing deep.
      
      There are a host of other changes as knock-on effects, and
      it all took FAR longer than I anticipated :-).  But it is
      a significant improvement, I think.
      
      Lots of error messages changed slightly, some just variants but
      some modest improvements.
      
      New tests
      
      * typecheck/should_compile
          * SigTyVars: a scoped-tyvar test
          * ExPat, ExPatFail: existential pattern bindings
          * T12069
          * T11700
          * T11339
      
      * partial-sigs/should_compile
          * T12033
          * T11339a
          * T11670
      
      One thing to check:
      
      * Small change to output from ghc-api/landmines.
        Need to check with Alan Zimmerman
      15b9bf4b
    • Simon Peyton Jones's avatar
      Kill off redundant SigTv check in occurCheckExpand · d25cb61a
      Simon Peyton Jones authored
      This patch simply deletes code, the SigTv check in
      occurCheckExpand.  As the new comment says
      
      In the past we also rejected a SigTv matched with a non-tyvar
      But it is wrong to reject that for Givens;
      and SigTv is in any case handled separately by
         - TcUnify.checkTauTvUpdate (on-the-fly unifier)
         - TcInteract.canSolveByUnification (main constraint solver)
      d25cb61a
  8. 10 Jun, 2016 1 commit
  9. 09 Jun, 2016 2 commits
  10. 07 Jun, 2016 4 commits
  11. 06 Jun, 2016 2 commits
    • Alan Zimmerman's avatar
      Merge MatchFixity and HsMatchContext · a13cb279
      Alan Zimmerman authored
      Summary:
      MatchFixity was introduced to facilitate use of API Annotations.
      
      HsMatchContext does the same thing with more detail, but is chased
      through all over the place to provide context when processing a Match.
      
      Since we already have MatchFixity in the Match, it may as well provide
      the full context.
      
      updates submodule haddock
      
      Test Plan: ./validate
      
      Reviewers: austin, goldfire, bgamari
      
      Subscribers: thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D2271
      
      GHC Trac Issues: #12105
      
      (cherry picked from commit 306ecad5)
      a13cb279
    • niteria's avatar
      Use UniqDFM for HomePackageTable · 3042a9d8
      niteria authored
      This isn't strictly necessary for deterministic ABIs.
      The results of eltsHpt are consumed in two ways:
      1) they determine the order of linking
      2) if you track the data flow all the family instances get put in
         FamInstEnvs, so the nondeterministic order is forgotten.
      3) same for VectInfo stuff
      4) same for Annotations
      
      The problem is that I haven't found a nice way to do 2. in
      a local way and 1. is nice to have if we went for deterministic
      object files. Besides these maps are keyed on ModuleNames so they
      should be small relative to other things and the overhead should
      be negligible.
      
      As a bonus we also get more specific names.
      
      Test Plan: ./validate
      
      Reviewers: bgamari, austin, hvr, ezyang, simonmar
      
      Reviewed By: simonmar
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2300
      
      GHC Trac Issues: #4012
      3042a9d8
  12. 03 Jun, 2016 1 commit
    • Ryan Scott's avatar
      Derive instances in Data.Data · 4842a805
      Ryan Scott authored
      Summary:
      Currently, none of the `Data` instances in `Data.Data` are derived,
      which has resulted in hundreds of lines of laboriously hand-written `Data`
      instances. This cleans it up by using `DeriveDataTypeable` to derive all of
      the boring instances.
      
      Note that previously, `tcTopSrcDecls` in `TcRnDriver` was typechecking the
      variables generated in `deriving` statements before other top-level variables,
      which causes an error when `DeriveDataTypeable` is used in `Data.Data`, since
      the `deriving`-generated variable definitions refer to top-level definitions
      in `Data.Data` itself. To fix this, the order in which these two groups are
      typechecked was reversed.
      
      Test Plan: ./validate
      
      Reviewers: rwbarton, bgamari, hvr, austin
      
      Reviewed By: austin
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2291
      4842a805
  13. 02 Jun, 2016 1 commit
  14. 27 May, 2016 1 commit