1. 21 Jun, 2016 2 commits
    • 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
  2. 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
  3. 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
  4. 14 Jun, 2016 2 commits
  5. 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
  6. 10 Jun, 2016 1 commit
  7. 09 Jun, 2016 2 commits
  8. 07 Jun, 2016 4 commits
  9. 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
  10. 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
  11. 02 Jun, 2016 1 commit
  12. 27 May, 2016 1 commit
  13. 26 May, 2016 1 commit
    • Simon Peyton Jones's avatar
      Reduce special-casing for nullary unboxed tuple · e9e61f18
      Simon Peyton Jones authored
      When we built the kind of a nullary unboxed tuple, we said, in
      TysWiredIn.mk_tuple:
      
          res_rep | arity == 0 = voidRepDataConTy
                        -- See Note [Nullary unboxed tuple] in Type
                  | otherwise  = unboxedTupleRepDataConTy
      
      But this is bogus.  The Note deals with what the 'unarise' transformation
      does, and up to that point it's simpler and more uniform to treat
      nullary unboxed tuples the same as all the others.
      
      Nicer now.  And it fixes the Lint error in Trac #12115
      e9e61f18
  14. 25 May, 2016 1 commit
  15. 24 May, 2016 4 commits
    • Ryan Scott's avatar
      Remove 'deriving Typeable' statements · 95dfdceb
      Ryan Scott authored
      Summary:
      Deriving `Typeable` has been a no-op since GHC 7.10, and now that we
      require 7.10+ to build GHC, we can remove all the redundant `deriving Typeable`
      statements in GHC.
      
      Test Plan: ./validate
      
      Reviewers: goldfire, austin, hvr, bgamari
      
      Reviewed By: austin, hvr, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2260
      95dfdceb
    • niteria's avatar
      Document some benign nondeterminism · 4c6e69d5
      niteria authored
      I've changed the functions to their nonDet equivalents and explained
      why they're OK there. This allowed me to remove foldNameSet,
      foldVarEnv, foldVarEnv_Directly, foldVarSet and foldUFM_Directly.
      
      Test Plan: ./validate, there should be no change in behavior
      
      Reviewers: simonpj, simonmar, austin, goldfire, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2244
      
      GHC Trac Issues: #4012
      4c6e69d5
    • Simon Peyton Jones's avatar
      Spelling in comment · eb8eb02b
      Simon Peyton Jones authored
      eb8eb02b
    • Simon Peyton Jones's avatar
      Don't split the arg types in a PatSyn signature · 03d89603
      Simon Peyton Jones authored
      This patch fixes Trac #11977, and #12108, rather satisfactorily
      maily by deleting code!
      
        pattern P :: Eq a => a -> a -> Int
      
      The idea is simply /not/ to split the bit after the '=>' into the
      pattern argument types, but to keep the (a->a->Int) part
      un-decomposed, in the patsig_body_ty field of a TcPatSynInfo.
      
      There is one awkward wrinkle, which is that we can't split the
      implicitly-bound type variables into existential and universal until
      we know which types are arguments and which are part of the result.
      So we postpone the decision until we have the declaration in hand.
      See TcPatSyn Note [The pattern-synonym signature splitting rule]
      03d89603
  16. 23 May, 2016 2 commits
  17. 21 May, 2016 1 commit
    • Andrew Farmer's avatar
      Fix deriving Ord when RebindableSyntax is enabled · 527ed724
      Andrew Farmer authored
      Deriving clauses (Ord especially) generated if-expressions with nlHsIf
      which were subject to RebindableSyntax. This changes nlHsIf to generate
      concrete if-expressions.
      
      There was also an error about calling tagToEnum# at a polymorphic type,
      which is not allowed. Fixing nlHsIf didn't fix this for some reason, so
      I generated a type ascription around the call to tagToEnum#. Not sure
      why the typechecker could not figure this out.
      
      Test Plan: Added a test, ran validate.
      
      Reviewers: simonpj, simonmar, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2247
      
      GHC Trac Issues: #12080
      527ed724
  18. 19 May, 2016 2 commits
  19. 18 May, 2016 2 commits
    • niteria's avatar
      Kill varEnvElts in tcPragExpr · 13e40f99
      niteria authored
      I had to refactor some things to take VarSet instead of [Var],
      but I think it's more precise this way.
      
      Test Plan: ./validate
      
      Reviewers: simonmar, simonpj, austin, bgamari, goldfire
      
      Reviewed By: simonpj
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2227
      
      GHC Trac Issues: #4012
      13e40f99
    • niteria's avatar
      Kill varSetElems in tidyFreeTyCoVars · 6282bc31
      niteria authored
      I haven't observed this to have an effect on nondeterminism,
      but tidyOccName appears to modify the TidyOccEnv in a
      way dependent on the order of inputs.
      It's easy enough to change it to be deterministic to be on the
      safe side.
      
      Test Plan: ./validate
      
      Reviewers: simonmar, austin, bgamari, simonpj
      
      Reviewed By: simonpj
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2238
      
      GHC Trac Issues: #4012
      6282bc31