1. 10 May, 2016 2 commits
    • Simon Peyton Jones's avatar
      Emit wild-card constraints in the right place · 76d9156f
      Simon Peyton Jones authored
      We were failing to emit wild-card hole constraints altogether
      in the case of pattern bindings.  Reason: it was done in
      tcExtendTyVarEnvFromSig, which isn't called for pattern bindings.
      
      This patch make it work right for both pattern and function
      bindings.  Mainly, there is a call to emitWildCardHolds in
      tcRhs for both PatBind and FunBind.
      
      I also killed off TcExpr.typeSigCtxt.
      76d9156f
    • Simon Peyton Jones's avatar
      White space only · 2593e204
      Simon Peyton Jones authored
      2593e204
  2. 28 Apr, 2016 2 commits
    • niteria's avatar
      Add uniqSetAny and uniqSetAll and use them · 3c426b05
      niteria authored
      There are couple of places where we do `foldUniqSet` just to
      compute `any` or `all`. `foldUniqSet` is non-deterministic in the
      general case and `any` and `all` also read nicer.
      
      Test Plan: ./validate
      
      Reviewers: simonmar, goldfire, simonpj, bgamari, austin
      
      Reviewed By: simonpj
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2156
      
      GHC Trac Issues: #4012
      3c426b05
    • Simon Peyton Jones's avatar
      Add missing solveEqualities · 4c746cb2
      Simon Peyton Jones authored
      I'd missed a call to solveEqualities in the partial-type-sig case
      of TcBinds.tcUserTypeSig.
      
      Also the checkValidType test done there best done after inference,
      in checkInferredPolyId (and is already done there).
      
      Fixes Trac #11976
      4c746cb2
  3. 07 Apr, 2016 1 commit
  4. 04 Apr, 2016 1 commit
    • Eric Seidel's avatar
      Don't infer CallStacks · 7407a66d
      Eric Seidel authored
      We originally wanted CallStacks to be opt-in, but dealing with let
      binders complicated things, forcing us to infer CallStacks. It turns
      out that the inference is actually unnecessary though, we can let the
      wanted CallStacks bubble up to the outer context by refusing to
      quantify over them. Eventually they'll be solved from a given CallStack
      or defaulted to the empty CallStack if they reach the top.
      
      So this patch prevents GHC from quantifying over CallStacks, getting us
      back to the original plan. There's a small ugliness to do with
      PartialTypeSignatures, if the partial theta contains a CallStack
      constraint, we *do* want to quantify over the CallStack; the user asked
      us to!
      
      Note that this means that
      
        foo :: _ => CallStack
        foo = getCallStack callStack
      
      will be an *empty* CallStack, since we won't infer a CallStack for the
      hole in the theta. I think this is the right move though, since we want
      CallStacks to be opt-in. One can always write
      
        foo :: (HasCallStack, _) => CallStack
        foo = getCallStack callStack
      
      to get the CallStack and still have GHC infer the rest of the theta.
      
      Test Plan: ./validate
      
      Reviewers: goldfire, simonpj, austin, hvr, bgamari
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: bitemyapp, thomie
      
      Projects: #ghc
      
      Differential Revision: https://phabricator.haskell.org/D1912
      
      GHC Trac Issues: #11573
      7407a66d
  5. 31 Mar, 2016 2 commits
  6. 25 Feb, 2016 2 commits
    • barrucadu's avatar
      Print which warning-flag controls an emitted warning · bb5afd3c
      barrucadu authored
      Both gcc and clang tell which warning flag a reported warning can be
      controlled with, this patch makes ghc do the same. More generally, this
      allows for annotated compiler output, where an optional annotation is
      displayed in brackets after the severity.
      
      This also adds a new flag `-f(no-)show-warning-groups` to control
      whether to show which warning-group (such as `-Wall` or `-Wcompat`)
      a warning belongs to. This flag is on by default.
      
      This implements #10752
      
      Reviewed By: quchen, bgamari, hvr
      
      Differential Revision: https://phabricator.haskell.org/D1943
      bb5afd3c
    • manav's avatar
      Make warning names more consistent · 66584914
      manav authored
      - Replace "Sigs" with "Signatures" in WarningFlag data constructors.
      - Replace "PatSyn" with "PatternSynonym" in WarningFlag data
        constructors.
      - Deprecate "missing-local-sigs" in favor of "missing-local-signatures".
      - Deprecate "missing-exported-sigs" in favor of
        "missing-exported-signatures".
      - Deprecate "missing-pat-syn-signatures" in favor of
        "missing-pattern-synonym-signatures".
      - Replace "ddump-strsigs" with "ddump-str-signatures"
      
      These complete the tasks that were explicitly mentioned in #11583
      
      Test Plan:
      Executed `ghc --show-options` and verified that the flags were changed
      as expected.
      
      Reviewers: svenpanne, austin, bgamari
      
      Reviewed By: austin, bgamari
      
      Subscribers: mpickering, thomie
      
      Differential Revision: https://phabricator.haskell.org/D1939
      
      GHC Trac Issues: #11583
      66584914
  7. 24 Feb, 2016 1 commit
    • eir@cis.upenn.edu's avatar
      Address #11471 by putting RuntimeRep in kinds. · d8c64e86
      eir@cis.upenn.edu authored
      See Note [TYPE] in TysPrim. There are still some outstanding
      pieces in #11471 though, so this doesn't actually nail the bug.
      
      This commit also contains a few performance improvements:
      
      * Short-cut equality checking of nullary type syns
      
      * Compare types before kinds in eqType
      
      * INLINE coreViewOneStarKind
      
      * Store tycon binders separately from kinds.
      
      This resulted in a ~10% performance improvement in compiling
      the Cabal package. No change in functionality other than
      performance. (This affects the interface file format, though.)
      
      This commit updates the haddock submodule.
      d8c64e86
  8. 12 Feb, 2016 1 commit
    • Simon Peyton Jones's avatar
      Simplify AbsBinds wrapping · c6485d5e
      Simon Peyton Jones authored
      In poking Trac #11414 I found myself sinking into the abe_inst_wrap
      swamp.  What is this strange thing?  (It turned out that #11414 was
      breaking because of it.)
      
      Thrillingly, I found a way to sweep it away again, putting the deep
      instantation into tcMonoBinds instead of mkExport; and it turned out
      that the fun_co_fn field of FunBind was already there ready to receive
      exactly this wrapper. Hooray.  Result
      
      * Death to abe_inst_wrap
      * Death to mbi_orig
      * Death to the plumbing in tcPolyInfer that did the
        deep instantiation
      
      I did find that I had to re-engineer the treatment of instance type
      signatures (again), but the result looks more modular and robust to
      me.
      
      And #11414 is fixed.
      c6485d5e
  9. 08 Feb, 2016 1 commit
    • Simon Peyton Jones's avatar
      Allow foralls in instance decls · 2cf3cac6
      Simon Peyton Jones authored
      This patch finally makes it possible to have explicit
      foralls in an instance decl
         instance forall (a :: *). Eq a => Eq [a] where ...
      
      This is useful to allow kind signatures or indeed
      explicicit kind for-alls; see Trac #11519
      
      I thought it would be really easy, because an instance
      declaration already contains an actual HsSigType, so all
      the syntactic baggage is there.  But in fact it turned
      out that instance declarations were kind-checked a
      little differently, because the body kind of the forall
      is 'Constraint' rather than '*'.
      
      So I fixed that.  There a slight kludge
      (see Note [Body kind of a HsQualTy], but it's still a
      significant improvement.
      
      I also did the usual other round of refactoring,
      improved a few error messages, tidied up comments etc.
      The only significant aspect of all that was
      
        * Kill mkNakedSpecSigmaTy, mkNakedPhiTy, mkNakedFunTy
          These function names suggest that they do something
          complicated, but acutally they do nothing. So I
          killed them.
      
        * Swap the arg order of mkNamedBinder, just so that it is
          convenient to say 'map (mkNamedBinder Invisible) tvs'
      
        * I had to improve isPredTy, to deal with (illegal)
          types like
             (Eq a => Eq [a]) => blah
          See Note [isPeredTy complications] in Type.hs
      
      Still to come: user manual documentation for the
      instance-decl change.
      2cf3cac6
  10. 27 Jan, 2016 2 commits
    • eir@cis.upenn.edu's avatar
      Refactor the typechecker to use ExpTypes. · 00cbbab3
      eir@cis.upenn.edu authored
      The idea here is described in [wiki:Typechecker]. Briefly,
      this refactor keeps solid track of "synthesis" mode vs
      "checking" in GHC's bidirectional type-checking algorithm.
      When in synthesis mode, the expected type is just an IORef
      to write to.
      
      In addition, this patch does a significant reworking of
      RebindableSyntax, allowing much more freedom in the types
      of the rebindable operators. For example, we can now have
      `negate :: Int -> Bool` and
      `(>>=) :: m a -> (forall x. a x -> m b) -> m b`. The magic
      is in tcSyntaxOp.
      
      This addresses tickets #11397, #11452, and #11458.
      
      Tests:
        typecheck/should_compile/{RebindHR,RebindNegate,T11397,T11458}
        th/T11452
      00cbbab3
    • Ömer Sinan Ağacan's avatar
      s/unLifted/unlifted for consistency · 4faa1a63
      Ömer Sinan Ağacan authored
      This was causing trouble as we had to remember when to use "unLifted"
      and when to use "unlifted".
      
      "unlifted" is used instead of "unLifted" as it's a single word.
      
      Reviewers: austin, hvr, goldfire, bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1852
      4faa1a63
  11. 21 Jan, 2016 1 commit
    • Simon Peyton Jones's avatar
      Re-add missing kind generalisation · c572430c
      Simon Peyton Jones authored
      When splitting H98/GADT syntax in ConDecl we lost a key
      kind-generalisation step.
      
      I also renamed tcHsTyVarBndrs to tcExplicitTKBnders, by analogy
      with tcImplicitTkBndrs.
      
      This fixes Trac #11459.
      
      Merge to 8.0.
      c572430c
  12. 18 Jan, 2016 3 commits
    • Jan Stolarek's avatar
      Replace calls to `ptext . sLit` with `text` · b8abd852
      Jan Stolarek authored
      Summary:
      In the past the canonical way for constructing an SDoc string literal was the
      composition `ptext . sLit`.  But for some time now we have function `text` that
      does the same.  Plus it has some rules that optimize its runtime behaviour.
      This patch takes all uses of `ptext . sLit` in the compiler and replaces them
      with calls to `text`.  The main benefits of this patch are clener (shorter) code
      and less dependencies between module, because many modules now do not need to
      import `FastString`.  I don't expect any performance benefits - we mostly use
      SDocs to report errors and it seems there is little to be gained here.
      
      Test Plan: ./validate
      
      Reviewers: bgamari, austin, goldfire, hvr, alanz
      
      Subscribers: goldfire, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D1784
      b8abd852
    • Simon Peyton Jones's avatar
      Implement scoped type variables in pattern synonyms · e2c7b7ee
      Simon Peyton Jones authored
      This fixes Trac #11351.   The implementation is pretty
      simple, happily.
      
      I took the opportunity to re-order the prov/req context
      in builder-ids, which was confusingly backwards.
      e2c7b7ee
    • Eric Seidel's avatar
      un-wire-in error, undefined, CallStack, and IP · a7b751db
      Eric Seidel authored
      I missed a crucial step in the wiring-in process of `CallStack` in D861,
      the bit where you actually wire-in the Name... This led to a nasty bug
      where GHC thought `CallStack` was not wired-in and tried to fingerprint
      it, which failed because the defining module was not loaded.
      
      But we don't need `CallStack` to be wired-in anymore since `error` and
      `undefined` no longer need to be wired-in. So we just remove them all.
      
      Updates haddock submodule.
      
      Test Plan: `./validate` and `make slowtest TEST=tc198`
      
      Reviewers: simonpj, goldfire, austin, hvr, bgamari
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: goldfire, thomie
      
      Projects: #ghc
      
      Differential Revision: https://phabricator.haskell.org/D1739
      
      GHC Trac Issues: #11331
      a7b751db
  13. 15 Jan, 2016 1 commit
    • eir@cis.upenn.edu's avatar
      Fix #11405. · 3c6635ef
      eir@cis.upenn.edu authored
      This adds a new variant of AbsBinds that is used solely for bindings
      with a type signature. This allows for a simpler desugaring that
      does not produce the bogus output that tripped up Core Lint in
      ticket #11405. Should make other desugarings simpler, too.
      3c6635ef
  14. 07 Jan, 2016 1 commit
  15. 24 Dec, 2015 1 commit
    • eir@cis.upenn.edu's avatar
      Visible type application · 2db18b81
      eir@cis.upenn.edu authored
      This re-working of the typechecker algorithm is based on
      the paper "Visible type application", by Richard Eisenberg,
      Stephanie Weirich, and Hamidhasan Ahmed, to be published at
      ESOP'16.
      
      This patch introduces -XTypeApplications, which allows users
      to say, for example `id @Int`, which has type `Int -> Int`. See
      the changes to the user manual for details.
      
      This patch addresses tickets #10619, #5296, #10589.
      2db18b81
  16. 23 Dec, 2015 1 commit
    • Simon Peyton Jones's avatar
      Add a pattern-syn form of PromotionErr · c069be81
      Simon Peyton Jones authored
      The main change is to add PatSynPE to PromotionErr, so that
      when we get an ill-staged use of a pattern synonym we get a
      civilised error message.
      
      We were already doing this in half-baked form in tcValBinds, but
      this patch tidies up the impl (which previously used a hack rather
      than APromotionErr), and does it in tcTyClsInstDecls too.
      c069be81
  17. 22 Dec, 2015 1 commit
    • Simon Peyton Jones's avatar
      Fix typechecking for pattern synonym signatures · f40e122b
      Simon Peyton Jones authored
      Various tickets have revealed bad shortcomings in the typechecking of
      pattern type synonyms.  Discussed a lot in (the latter part of)
      Trac #11224.
      
      This patch fixes the most complex issues:
      
      - Both parser and renamer now treat pattern synonyms as an
        ordinary LHsSigType.  Nothing special.  Hooray.
      
      - tcPatSynSig (now in TcPatSyn) typechecks the signature, and
        decomposes it into its pieces.
        See Note [Pattern synonym signatures]
      
      - tcCheckPatSyn has had a lot of refactoring.
        See Note [Checking against a pattern signature]
      
      The result is a lot tidier and more comprehensible.
      Plus, it actually works!
      
      NB: this patch doesn't actually address the precise
          target of #11224, namely "inlining pattern synonym
          does not preserve semantics".  That's an unrelated
          bug, with a separate patch.
      
      ToDo: better documentation in the user manual
      
      Test Plan: Validate
      
      Reviewers: austin, hvr, goldfire
      
      Subscribers: goldfire, mpickering, thomie, simonpj
      
      Differential Revision: https://phabricator.haskell.org/D1685
      
      GHC Trac Issues: #11224
      f40e122b
  18. 15 Dec, 2015 1 commit
    • Ben Gamari's avatar
      Expose enabled language extensions to TH · c1e25536
      Ben Gamari authored
      This exposes `template-haskell` functions for querying the language
      extensions which are enabled when compiling a module,
      
      - an `isExtEnabled` function to check whether an extension is enabled
      - an `extsEnabled` function to obtain a full list of enabled extensions
      
      To avoid code duplication this adds a `GHC.LanguageExtensions` module to
      `ghc-boot` and moves `DynFlags.ExtensionFlag` into it. A happy
      consequence of this is that the ungainly `DynFlags` lost around 500
      lines. Moreover, flags corresponding to language extensions are now
      clearly distinguished from other flags due to the `LangExt.*` prefix.
      
      Updates haddock submodule.
      
      This fixes #10820.
      
      Test Plan: validate
      
      Reviewers: austin, spinda, hvr, goldfire, alanz
      
      Reviewed By: goldfire
      
      Subscribers: mpickering, RyanGlScott, hvr, simonpj, thomie
      
      Differential Revision: https://phabricator.haskell.org/D1200
      
      GHC Trac Issues: #10820
      c1e25536
  19. 11 Dec, 2015 2 commits
    • eir@cis.upenn.edu's avatar
      Add kind equalities to GHC. · 67465497
      eir@cis.upenn.edu authored
      This implements the ideas originally put forward in
      "System FC with Explicit Kind Equality" (ICFP'13).
      
      There are several noteworthy changes with this patch:
       * We now have casts in types. These change the kind
         of a type. See new constructor `CastTy`.
      
       * All types and all constructors can be promoted.
         This includes GADT constructors. GADT pattern matches
         take place in type family equations. In Core,
         types can now be applied to coercions via the
         `CoercionTy` constructor.
      
       * Coercions can now be heterogeneous, relating types
         of different kinds. A coercion proving `t1 :: k1 ~ t2 :: k2`
         proves both that `t1` and `t2` are the same and also that
         `k1` and `k2` are the same.
      
       * The `Coercion` type has been significantly enhanced.
         The documentation in `docs/core-spec/core-spec.pdf` reflects
         the new reality.
      
       * The type of `*` is now `*`. No more `BOX`.
      
       * Users can write explicit kind variables in their code,
         anywhere they can write type variables. For backward compatibility,
         automatic inference of kind-variable binding is still permitted.
      
       * The new extension `TypeInType` turns on the new user-facing
         features.
      
       * Type families and synonyms are now promoted to kinds. This causes
         trouble with parsing `*`, leading to the somewhat awkward new
         `HsAppsTy` constructor for `HsType`. This is dispatched with in
         the renamer, where the kind `*` can be told apart from a
         type-level multiplication operator. Without `-XTypeInType` the
         old behavior persists. With `-XTypeInType`, you need to import
         `Data.Kind` to get `*`, also known as `Type`.
      
       * The kind-checking algorithms in TcHsType have been significantly
         rewritten to allow for enhanced kinds.
      
       * The new features are still quite experimental and may be in flux.
      
       * TODO: Several open tickets: #11195, #11196, #11197, #11198, #11203.
      
       * TODO: Update user manual.
      
      Tickets addressed: #9017, #9173, #7961, #10524, #8566, #11142.
      Updates Haddock submodule.
      67465497
    • Matthew Pickering's avatar
      Make sure PatSyns only get added once to tcg_patsyns · 41ef8f70
      Matthew Pickering authored
      Summary: Before, `PatSyn`s were getting added twice to `tcg_patsyns` so
      when inspecting afterwards there were duplicates in the list.
      This makes sure that only they only get added once.
      
      Reviewers: austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1597
      41ef8f70
  20. 09 Dec, 2015 1 commit
  21. 08 Dec, 2015 1 commit
  22. 07 Dec, 2015 1 commit
  23. 04 Dec, 2015 2 commits
    • Simon Peyton Jones's avatar
      Tidy user type errors in checkValidType · 67565a72
      Simon Peyton Jones authored
      Trac #11144 showed that we need to tidy the type in the error message
      generated in TcValidity.checkUserTypeError.
      
      This is still unsatisfactory.  checkValidType was originally supposed
      to be called only on types gotten directly from user-written HsTypes.
      So its error messages do no tidying.  But TcBinds calls it checkValidType
      on an /inferred/ type, which may need tidying.
      
      Still this at least fixes the bad error message in CustomTypeErrors02,
      which was the original ticket.
      
      Some other small refactorings:
      
      * Remove unused Kind result of getUserTypeErrorMsg
      * Rename isUserErrorTy  -->   userTypeError_maybe
      67565a72
    • Simon Peyton Jones's avatar
      Wibbles only · 1cb3c8c2
      Simon Peyton Jones authored
      1cb3c8c2
  24. 01 Dec, 2015 1 commit
    • Simon Peyton Jones's avatar
      Refactor treatment of wildcards · 1e041b73
      Simon Peyton Jones authored
      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
      
      Updates haddock submodule.
      1e041b73
  25. 22 Nov, 2015 1 commit
    • Alan Zimmerman's avatar
      ApiAnnotations: Make all RdrName occurences Located · 3df9563e
      Alan Zimmerman authored
      At the moment the API Annotations can only be used on the ParsedSource,
      as there are changes made to the RenamedSource that prevent it from
      being used to round trip source code.
      
      It is possible to build a map from every Located Name in the
      RenamedSource from its location to the Name, which can then be used when
      resolved names are required when changing the ParsedSource.
      
      However, there are instances where the identifier is not located,
      specifically
      
        (GHC.VarPat name)
        (GHC.HsVar name)
        (GHC.UserTyVar name)
        (GHC.HsTyVar name)
      
      Replace each of the name types above with (Located name)
      
      Updates the haddock submodule.
      
      Test Plan: ./validate
      
      Reviewers: austin, goldfire, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: goldfire, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D1512
      
      GHC Trac Issues: #11019
      3df9563e
  26. 16 Nov, 2015 1 commit
  27. 14 Nov, 2015 1 commit
  28. 13 Nov, 2015 1 commit
    • Alan Zimmerman's avatar
      APIAnnotations:add Locations in hsSyn for layout · 2290c8bd
      Alan Zimmerman authored
      Summary:
      At the moment ghc-exactprint, which uses the GHC API Annotations to
      provide a framework for roundtripping Haskell source code with optional
      AST edits, has to implement a horrible workaround to manage the points
      where layout needs to be captured.
      
      These are
      
          MatchGroup
          HsDo
          HsCmdDo
          HsLet
          LetStmt
          HsCmdLet
          GRHSs
      
      To provide a more natural representation, the contents subject to layout
      rules need to be wrapped in a SrcSpan.
      
      This commit does this.
      
      Trac ticket #10250
      
      Test Plan: ./validate
      
      Reviewers: hvr, goldfire, bgamari, austin, mpickering
      
      Reviewed By: mpickering
      
      Subscribers: thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D1370
      
      GHC Trac Issues: #10250
      2290c8bd
  29. 11 Nov, 2015 1 commit
    • Alan Zimmerman's avatar
      Remove fun_infix from Funbind, as it is now in Match · f0f9365f
      Alan Zimmerman authored
      One of the changes D538 introduced is to add `m_fun_id_infix` to `Match`
      
      ```lang=hs
      data Match id body
        = Match {
              m_fun_id_infix :: (Maybe (Located id,Bool)),
                -- fun_id and fun_infix for functions with multiple equations
                -- only present for a RdrName. See note [fun_id in Match]
              m_pats :: [LPat id], -- The patterns
              m_type :: (Maybe (LHsType id)),
                                       -- A type signature for the result of the match
                                       -- Nothing after typechecking
              m_grhss :: (GRHSs id body)
        } deriving (Typeable)
      ```
      
      This was done to track the individual locations and fixity of the
      `fun_id` for each of the defining equations for a function when there
      are more than one.
      
      For example, the function `(&&&)` is defined with some prefix and some
      infix equations below.
      
      ```lang=hs
          (&&&  ) [] [] =  []
          xs    &&&   [] =  xs
          (  &&&  ) [] ys =  ys
      ```
      
      This means that the fun_infix is now superfluous in the `FunBind`. This
      has not been removed as a potentially risky change just before 7.10 RC2,
      and so must be done after.
      
      This ticket captures that task, which includes processing these fields
      through the renamer and beyond.
      
      Ticket #9988 introduced these fields into `Match` through renaming, this
      ticket it to continue through type checking and then remove it from
      `FunBind` completely.
      
      The split happened so that #9988 could land in 7.10
      
      Trac ticket : #10061
      
      Test Plan: ./validate
      
      Reviewers: goldfire, austin, simonpj, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: simonpj, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D1285
      
      GHC Trac Issues: #10061
      f0f9365f
  30. 30 Oct, 2015 1 commit
    • Ben Gamari's avatar
      Generate Typeable info at definition sites · 91c6b1f5
      Ben Gamari authored
      This is the second attempt at merging D757.
      
      This patch implements the idea floated in Trac #9858, namely that we
      should generate type-representation information at the data type
      declaration site, rather than when solving a Typeable constraint.
      
      However, this turned out quite a bit harder than I expected. I still
      think it's the right thing to do, and it's done now, but it was quite
      a struggle.
      
      See particularly
      
       * Note [Grand plan for Typeable] in TcTypeable (which is a new module)
       * Note [The overall promotion story] in DataCon (clarifies existing
      stuff)
      
      The most painful bit was that to generate Typeable instances (ie
      TyConRepName bindings) for every TyCon is tricky for types in ghc-prim
      etc:
      
       * We need to have enough data types around to *define* a TyCon
       * Many of these types are wired-in
      
      Also, to minimise the code generated for each data type, I wanted to
      generate pure data, not CAFs with unpackCString# stuff floating about.
      
      Performance
      ~~~~~~~~~~~
      Three perf/compiler tests start to allocate quite a bit more. This isn't
      surprising, because they all allocate zillions of data types, with
      practically no other code, esp. T1969
      
       * T1969:    GHC allocates 19% more
       * T4801:    GHC allocates 13% more
       * T5321FD:  GHC allocates 13% more
       * T9675:    GHC allocates 11% more
       * T783:     GHC allocates 11% more
       * T5642:    GHC allocates 10% more
      
      I'm treating this as acceptable. The payoff comes in Typeable-heavy
      code.
      
      Remaining to do
      ~~~~~~~~~~~~~~~
      
       * I think that "TyCon" and "Module" are over-generic names to use for
         the runtime type representations used in GHC.Typeable. Better might
      be
         "TrTyCon" and "TrModule". But I have not yet done this
      
       * Add more info the the "TyCon" e.g. source location where it was
         defined
      
       * Use the new "Module" type to help with Trac Trac #10068
      
       * It would be possible to generate TyConRepName (ie Typeable
         instances) selectively rather than all the time. We'd need to persist
         the information in interface files. Lacking a motivating reason I
      have
         not done this, but it would not be difficult.
      
      Refactoring
      ~~~~~~~~~~~
      As is so often the case, I ended up refactoring more than I intended.
      In particular
      
       * In TyCon, a type *family* (whether type or data) is repesented by a
         FamilyTyCon
           * a algebraic data type (including data/newtype instances) is
             represented by AlgTyCon This wasn't true before; a data family
             was represented as an AlgTyCon. There are some corresponding
             changes in IfaceSyn.
      
           * Also get rid of the (unhelpfully named) tyConParent.
      
       * In TyCon define 'Promoted', isomorphic to Maybe, used when things are
         optionally promoted; and use it elsewhere in GHC.
      
       * Cleanup handling of knownKeyNames
      
       * Each TyCon, including promoted TyCons, contains its TyConRepName, if
         it has one. This is, in effect, the name of its Typeable instance.
      
      Updates haddock submodule
      
      Test Plan: Let Harbormaster validate
      
      Reviewers: austin, hvr, goldfire
      
      Subscribers: goldfire, thomie
      
      Differential Revision: https://phabricator.haskell.org/D1404
      
      GHC Trac Issues: #9858
      91c6b1f5
  31. 29 Oct, 2015 1 commit