Skip to content
Snippets Groups Projects
  1. Jul 05, 2023
    • Vladislav Zavialov's avatar
      testsuite: Do not require CUSKs · 679bbc97
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      Numerous tests make use of CUSKs (complete user-supplied kinds),
      a legacy feature scheduled for deprecation. In order to proceed
      with the said deprecation, the tests have been updated to use SAKS
      instead (standalone kind signatures).
      
      This also allows us to remove the Haskell2010 language pragmas that
      were added in 115cd3c8 to work around the lack of CUSKs in GHC2021.
      679bbc97
  2. Jun 15, 2023
    • Andrei Borzenkov's avatar
      Report scoped kind variables at the type-checking phase (#16635) · 78cd1132
      Andrei Borzenkov authored
      This patch modifies the renamer to respect ScopedTypeVariables in kind
      signatures. This means that kind variables bound by the outermost
      `forall` now scope over the type:
      
        type F = '[Right @a @() () :: forall a. Either a ()]
        --         ^^^^^^^^^^^^^^^          ^^^
        --          in scope here        bound here
      
      However, any use of such variables is a type error, because we don't
      have type-level lambdas to bind them in Core. This is described in the
      new Note [Type variable scoping errors during type check] in GHC.Tc.Types.
      78cd1132
  3. Jun 14, 2023
  4. Jun 07, 2023
    • Vladislav Zavialov's avatar
      Invisible binders in type declarations (#22560) · 4aea0a72
      Vladislav Zavialov authored
      
      This patch implements @k-binders introduced in GHC Proposal #425
      and guarded behind the TypeAbstractions extension:
      
      	type D :: forall k j. k -> j -> Type
      	data D @k @j a b = ...
      	       ^^ ^^
      
      To represent the new syntax, we modify LHsQTyVars as follows:
      
      	-  hsq_explicit :: [LHsTyVarBndr () pass]
      	+  hsq_explicit :: [LHsTyVarBndr (HsBndrVis pass) pass]
      
      HsBndrVis is a new data type that records the distinction between
      type variable binders written with and without the @ sign:
      
      	data HsBndrVis pass
      	  = HsBndrRequired
      	  | HsBndrInvisible (LHsToken "@" pass)
      
      The rest of the patch updates GHC, template-haskell, and haddock
      to handle the new syntax.
      
      Parser:
        The PsErrUnexpectedTypeAppInDecl error message is removed.
        The syntax it used to reject is now permitted.
      
      Renamer:
        The @ sign does not affect the scope of a binder, so the changes to
        the renamer are minimal.  See rnLHsTyVarBndrVisFlag.
      
      Type checker:
        There are three code paths that were updated to deal with the newly
        introduced invisible type variable binders:
      
          1. checking SAKS: see kcCheckDeclHeader_sig, matchUpSigWithDecl
          2. checking CUSK: see kcCheckDeclHeader_cusk
          3. inference: see kcInferDeclHeader, rejectInvisibleBinders
      
        Helper functions bindExplicitTKBndrs_Q_Skol and bindExplicitTKBndrs_Q_Tv
        are generalized to work with HsBndrVis.
      
      Updates the haddock submodule.
      
      Metric Increase:
          MultiLayerModulesTH_OneShot
      
      Co-authored-by: default avatarSimon Peyton Jones <simon.peytonjones@gmail.com>
      4aea0a72
  5. May 24, 2023
    • Hai Nguyen Quang's avatar
      Migrate errors in GHC.Tc.Validity · 838aaf4b
      Hai Nguyen Quang authored and Marge Bot's avatar Marge Bot committed
      This patch migrates the error messages in GHC.Tc.Validity to use
      the new diagnostic infrastructure.
      
      It adds the constructors:
      
        - TcRnSimplifiableConstraint
        - TcRnArityMismatch
        - TcRnIllegalInstanceDecl, with sub-datatypes for HasField errors
          and fundep coverage condition errors.
      838aaf4b
  6. May 13, 2023
    • Simon Peyton Jones's avatar
      Use the eager unifier in the constraint solver · 8b9b7dbc
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      This patch continues the refactoring of the constraint solver
      described in #23070.
      
      The Big Deal in this patch is to call the regular, eager unifier from the
      constraint solver, when we want to create new equalities. This
      replaces the existing, unifyWanted which amounted to
      yet-another-unifier, so it reduces duplication of a rather subtle
      piece of technology. See
      
        * Note [The eager unifier] in GHC.Tc.Utils.Unify
        * GHC.Tc.Solver.Monad.wrapUnifierTcS
      
      I did lots of other refactoring along the way
      
      * I simplified the treatment of right hand sides that contain CoercionHoles.
        Now, a constraint that contains a hetero-kind CoercionHole is non-canonical,
        and cannot be used for rewriting or unification alike.  This required me
        to add the ch_hertero_kind flag to CoercionHole, with consequent knock-on
        effects. See wrinkle (2) of `Note [Equalities with incompatible kinds]` in
        GHC.Tc.Solver.Equality.
      
      * I refactored the StopOrContinue type to add StartAgain, so that after a
        fundep improvement (for example) we can simply start the pipeline again.
      
      * I got rid of the unpleasant (and inefficient) rewriterSetFromType/Co functions.
        With Richard I concluded that they are never needed.
      
      * I discovered Wrinkle (W1) in Note [Wanteds rewrite Wanteds] in
        GHC.Tc.Types.Constraint, and therefore now prioritise non-rewritten equalities.
      
      Quite a few error messages change, I think always for the better.
      
      Compiler runtime stays about the same, with one outlier: a 17% improvement in T17836
      
      Metric Decrease:
          T17836
          T18223
      8b9b7dbc
  7. May 06, 2023
  8. May 05, 2023
  9. Apr 14, 2023
    • Simon Peyton Jones's avatar
      Major refactor in the handling of equality constraints · 2371d6b2
      Simon Peyton Jones authored and Krzysztof Gogolewski's avatar Krzysztof Gogolewski committed
      This MR substantially refactors the way in which the constraint
      solver deals with equality constraints.  The big thing is:
      
      * Intead of a pipeline in which we /first/ canonicalise and /then/
        interact (the latter including performing unification) the two steps
        are more closely integreated into one.  That avoids the current
        rather indirect communication between the two steps.
      
      The proximate cause for this refactoring is fixing #22194, which involve
      solving   [W] alpha[2] ~ Maybe (F beta[4])
      by doing this:
                alpha[2] := Maybe delta[2]
                [W] delta[2] ~ F beta[4]
      That is, we don't promote beta[4]!  This is very like introducing a cycle
      breaker, and was very awkward to do before, but now it is all nice.
      See GHC.Tc.Utils.Unify Note [Promotion and level-checking] and
      Note [Family applications in canonical constraints].
      
      The big change is this:
      
      * Several canonicalisation checks (occurs-check, cycle-breaking,
        checking for concreteness) are combined into one new function:
           GHC.Tc.Utils.Unify.checkTyEqRhs
      
        This function is controlled by `TyEqFlags`, which says what to do
        for foralls, type families etc.
      
      * `canEqCanLHSFinish` now sees if unification is possible, and if so,
        actually does it: see `canEqCanLHSFinish_try_unification`.
      
      There are loads of smaller changes:
      
      * The on-the-fly unifier `GHC.Tc.Utils.Unify.unifyType` has a
        cheap-and-cheerful version of `checkTyEqRhs`, called
        `simpleUnifyCheck`.  If `simpleUnifyCheck` succeeds, it can unify,
        otherwise it defers by emitting a constraint. This is simpler than
        before.
      
      * I simplified the swapping code in `GHC.Tc.Solver.Equality.canEqCanLHS`.
        Especially the nasty stuff involving `swap_for_occurs` and
        `canEqTyVarFunEq`.  Much nicer now.  See
            Note [Orienting TyVarLHS/TyFamLHS]
            Note [Orienting TyFamLHS/TyFamLHS]
      
      * Added `cteSkolemOccurs`, `cteConcrete`, and `cteCoercionHole` to the
        problems that can be discovered by `checkTyEqRhs`.
      
      * I fixed #23199 `pickQuantifiablePreds`, which actually allows GHC to
        to accept both cases in #22194 rather than rejecting both.
      
      Yet smaller:
      
      * Added a `synIsConcrete` flag to `SynonymTyCon` (alongside `synIsFamFree`)
        to reduce the need for synonym expansion when checking concreteness.
        Use it in `isConcreteType`.
      
      * Renamed `isConcrete` to `isConcreteType`
      
      * Defined `GHC.Core.TyCo.FVs.isInjectiveInType` as a more efficient
        way to find if a particular type variable is used injectively than
        finding all the injective variables.  It is called in
        `GHC.Tc.Utils.Unify.definitely_poly`, which in turn is used quite a
        lot.
      
      * Moved `rewriterView` to `GHC.Core.Type`, so we can use it from the
        constraint solver.
      
      Fixes #22194, #23199
      
      Compile times decrease by an average of 0.1%; but there is a 7.4%
      drop in compiler allocation on T15703.
      
      Metric Decrease:
          T15703
      2371d6b2
  10. Apr 03, 2023
    • Haskell-mouse's avatar
      Convert diagnostics in GHC.Rename.HsType to proper TcRnMessage · 8b092910
      Haskell-mouse authored and Marge Bot's avatar Marge Bot committed
      I've turned all occurrences of TcRnUnknownMessage in GHC.Rename.HsType
      module into a proper TcRnMessage.
      Instead, these TcRnMessage messages were introduced:
      
      TcRnDataKindsError
      TcRnUnusedQuantifiedTypeVar
      TcRnIllegalKindSignature
      TcRnUnexpectedPatSigType
      TcRnSectionPrecedenceError
      TcRnPrecedenceParsingError
      TcRnIllegalKind
      TcRnNegativeNumTypeLiteral
      TcRnUnexpectedKindVar
      TcRnBindMultipleVariables
      TcRnBindVarAlreadyInScope
      8b092910
  11. Apr 01, 2023
  12. Mar 22, 2023
  13. Mar 06, 2023
    • Andrei Borzenkov's avatar
      Convert diagnostics in GHC.Rename.Module to proper TcRnMessage (#20115) · cad5c576
      Andrei Borzenkov authored and Marge Bot's avatar Marge Bot committed
      I've turned almost all occurrences of TcRnUnknownMessage in GHC.Rename.Module
      module into a proper TcRnMessage.
      Instead, these TcRnMessage messages were introduced:
        TcRnIllegalInstanceHeadDecl
        TcRnUnexpectedStandaloneDerivingDecl
        TcRnUnusedVariableInRuleDecl
        TcRnUnexpectedStandaloneKindSig
        TcRnIllegalRuleLhs
        TcRnBadAssocRhs
        TcRnDuplicateRoleAnnot
        TcRnDuplicateKindSig
        TcRnIllegalDerivStrategy
        TcRnIllegalMultipleDerivClauses
        TcRnNoDerivStratSpecified
        TcRnStupidThetaInGadt
        TcRnBadImplicitSplice
        TcRnShadowedTyVarNameInFamResult
        TcRnIncorrectTyVarOnLhsOfInjCond
        TcRnUnknownTyVarsOnRhsOfInjCond
      
      Was introduced one helper type:
        RuleLhsErrReason
      cad5c576
  14. Mar 04, 2023
  15. Jan 23, 2023
    • Simon Peyton Jones's avatar
      Fix #22742 · 82884ce0
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      runtimeRepLevity_maybe was panicing unnecessarily; and
      the error printing code made use of the case when it should
      return Nothing rather than panicing.
      
      For some bizarre reason perf/compiler/T21839r shows a 10% bump in runtime
      peak-megagbytes-used, on a single architecture (alpine). See !9753 for
      commentary, but I'm going to accept it.
      
      Metric Increase:
          T21839r
      82884ce0
  16. Jan 13, 2023
  17. Dec 24, 2022
    • Richard Eisenberg's avatar
      Drop support for kind constraints. · 3c3060e4
      Richard Eisenberg authored and Matthew Pickering's avatar Matthew Pickering committed
      This implements proposal 547 and closes ticket #22298.
      See the proposal and ticket for motivation.
      
      Compiler perf improves a bit
      
      Metrics: compile_time/bytes allocated
      -------------------------------------
        CoOpt_Singletons(normal)   -2.4% GOOD
                  T12545(normal)   +1.0%
                  T13035(normal)  -13.5% GOOD
                  T18478(normal)   +0.9%
                  T9872d(normal)   -2.2% GOOD
      
                       geo. mean   -0.2%
                       minimum    -13.5%
                       maximum     +1.0%
      
      Metric Decrease:
          CoOpt_Singletons
          T13035
          T9872d
      3c3060e4
  18. Nov 29, 2022
    • Apoorv Ingle's avatar
      Killing cc_fundeps, streamlining kind equality orientation, and type equality processing order · 8d15eadc
      Apoorv Ingle authored and Marge Bot's avatar Marge Bot committed
      Fixes: #217093
      Associated to #19415
      
      This change
      * Flips the orientation of the the generated kind equality coercion in canEqLHSHetero;
      * Removes `cc_fundeps` in CDictCan as the check was incomplete;
      * Changes `canDecomposableTyConAppOk` to ensure we process kind equalities before type equalities and avoiding a call to `canEqLHSHetero` while processing wanted TyConApp equalities
      * Adds 2 new tests for validating the change
         - testsuites/typecheck/should_compile/T21703.hs and
         - testsuites/typecheck/should_fail/T19415b.hs (a simpler version of T19415.hs)
      * Misc: Due to the change in the equality direction some error messages now have flipped type mismatch errors
      * Changes in Notes:
        - Note [Fundeps with instances, and equality orientation] supercedes Note [Fundeps with instances]
        - Added Note [Kind Equality Orientation] to visualize the kind flipping
        - Added Note [Decomposing Dependent TyCons and Processing Wanted Equalties]
      8d15eadc
  19. Nov 25, 2022
    • Vladislav Zavialov's avatar
      Print unticked promoted data constructors (#20531) · 13d627bb
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      
      Before this patch, GHC unconditionally printed ticks before promoted
      data constructors:
      
      	ghci> type T = True  -- unticked (user-written)
      	ghci> :kind! T
      	T :: Bool
      	= 'True              -- ticked (compiler output)
      
      After this patch, GHC prints ticks only when necessary:
      
      	ghci> type F = False    -- unticked (user-written)
      	ghci> :kind! F
      	F :: Bool
      	= False                 -- unticked (compiler output)
      
      	ghci> data False        -- introduce ambiguity
      	ghci> :kind! F
      	F :: Bool
      	= 'False                -- ticked by necessity (compiler output)
      
      The old behavior can be enabled by -fprint-redundant-promotion-ticks.
      
      Summary of changes:
      * Rename PrintUnqualified to NamePprCtx
      * Add QueryPromotionTick to it
      * Consult the GlobalRdrEnv to decide whether to print a tick (see mkPromTick)
      * Introduce -fprint-redundant-promotion-ticks
      
      Co-authored-by: default avatarArtyom Kuznetsov <hi@wzrd.ht>
      13d627bb
  20. Nov 11, 2022
    • Simon Peyton Jones's avatar
      Type vs Constraint: finally nailed · 778c6adc
      Simon Peyton Jones authored and Simon Peyton Jones's avatar Simon Peyton Jones committed
      This big patch addresses the rats-nest of issues that have plagued
      us for years, about the relationship between Type and Constraint.
      See #11715/#21623.
      
      The main payload of the patch is:
      * To introduce CONSTRAINT :: RuntimeRep -> Type
      * To make TYPE and CONSTRAINT distinct throughout the compiler
      
      Two overview Notes in GHC.Builtin.Types.Prim
      
      * Note [TYPE and CONSTRAINT]
      
      * Note [Type and Constraint are not apart]
        This is the main complication.
      
      The specifics
      
      * New primitive types (GHC.Builtin.Types.Prim)
        - CONSTRAINT
        - ctArrowTyCon (=>)
        - tcArrowTyCon (-=>)
        - ccArrowTyCon (==>)
        - funTyCon     FUN     -- Not new
        See Note [Function type constructors and FunTy]
        and Note [TYPE and CONSTRAINT]
      
      * GHC.Builtin.Types:
        - New type Constraint = CONSTRAINT LiftedRep
        - I also stopped nonEmptyTyCon being built-in; it only needs to be wired-in
      
      * Exploit the fact that Type and Constraint are distinct throughout GHC
        - Get rid of tcView in favour of coreView.
        - Many tcXX functions become XX functions.
          e.g. tcGetCastedTyVar --> getCastedTyVar
      
      * Kill off Note [ForAllTy and typechecker equality], in (old)
        GHC.Tc.Solver.Canonical.  It said that typechecker-equality should ignore
        the specified/inferred distinction when comparein two ForAllTys.  But
        that wsa only weakly supported and (worse) implies that we need a separate
        typechecker equality, different from core equality. No no no.
      
      * GHC.Core.TyCon: kill off FunTyCon in data TyCon.  There was no need for it,
        and anyway now we have four of them!
      
      * GHC.Core.TyCo.Rep: add two FunTyFlags to FunCo
        See Note [FunCo] in that module.
      
      * GHC.Core.Type.  Lots and lots of changes driven by adding CONSTRAINT.
        The key new function is sORTKind_maybe; most other changes are built
        on top of that.
      
        See also `funTyConAppTy_maybe` and `tyConAppFun_maybe`.
      
      * Fix a longstanding bug in GHC.Core.Type.typeKind, and Core Lint, in
        kinding ForAllTys.  See new tules (FORALL1) and (FORALL2) in GHC.Core.Type.
        (The bug was that before (forall (cv::t1 ~# t2). blah), where
        blah::TYPE IntRep, would get kind (TYPE IntRep), but it should be
        (TYPE LiftedRep).  See Note [Kinding rules for types] in GHC.Core.Type.
      
      * GHC.Core.TyCo.Compare is a new module in which we do eqType and cmpType.
        Of course, no tcEqType any more.
      
      * GHC.Core.TyCo.FVs. I moved some free-var-like function into this module:
        tyConsOfType, visVarsOfType, and occCheckExpand.  Refactoring only.
      
      * GHC.Builtin.Types.  Compiletely re-engineer boxingDataCon_maybe to
        have one for each /RuntimeRep/, rather than one for each /Type/.
        This dramatically widens the range of types we can auto-box.
        See Note [Boxing constructors] in GHC.Builtin.Types
        The boxing types themselves are declared in library ghc-prim:GHC.Types.
      
        GHC.Core.Make.  Re-engineer the treatment of "big" tuples (mkBigCoreVarTup
        etc) GHC.Core.Make, so that it auto-boxes unboxed values and (crucially)
        types of kind Constraint. That allows the desugaring for arrows to work;
        it gathers up free variables (including dictionaries) into tuples.
        See  Note [Big tuples] in GHC.Core.Make.
      
        There is still work to do here: #22336. But things are better than
        before.
      
      * GHC.Core.Make.  We need two absent-error Ids, aBSENT_ERROR_ID for types of
        kind Type, and aBSENT_CONSTRAINT_ERROR_ID for vaues of kind Constraint.
        Ditto noInlineId vs noInlieConstraintId in GHC.Types.Id.Make;
        see Note [inlineId magic].
      
      * GHC.Core.TyCo.Rep. Completely refactor the NthCo coercion.  It is now called
        SelCo, and its fields are much more descriptive than the single Int we used to
        have.  A great improvement.  See Note [SelCo] in GHC.Core.TyCo.Rep.
      
      * GHC.Core.RoughMap.roughMatchTyConName.  Collapse TYPE and CONSTRAINT to
        a single TyCon, so that the rough-map does not distinguish them.
      
      * GHC.Core.DataCon
        - Mainly just improve documentation
      
      * Some significant renamings:
        GHC.Core.Multiplicity: Many -->  ManyTy (easier to grep for)
                               One  -->  OneTy
        GHC.Core.TyCo.Rep TyCoBinder      -->   GHC.Core.Var.PiTyBinder
        GHC.Core.Var      TyCoVarBinder   -->   ForAllTyBinder
                          AnonArgFlag     -->   FunTyFlag
                          ArgFlag         -->   ForAllTyFlag
        GHC.Core.TyCon    TyConTyCoBinder --> TyConPiTyBinder
        Many functions are renamed in consequence
        e.g. isinvisibleArgFlag becomes isInvisibleForAllTyFlag, etc
      
      * I refactored FunTyFlag (was AnonArgFlag) into a simple, flat data type
          data FunTyFlag
            = FTF_T_T           -- (->)  Type -> Type
            | FTF_T_C           -- (-=>) Type -> Constraint
            | FTF_C_T           -- (=>)  Constraint -> Type
            | FTF_C_C           -- (==>) Constraint -> Constraint
      
      * GHC.Tc.Errors.Ppr.  Some significant refactoring in the TypeEqMisMatch case
        of pprMismatchMsg.
      
      * I made the tyConUnique field of TyCon strict, because I
        saw code with lots of silly eval's.  That revealed that
        GHC.Settings.Constants.mAX_SUM_SIZE can only be 63, because
        we pack the sum tag into a 6-bit field.  (Lurking bug squashed.)
      
      Fixes
      * #21530
      
      Updates haddock submodule slightly.
      
      Performance changes
      ~~~~~~~~~~~~~~~~~~~
      I was worried that compile times would get worse, but after
      some careful profiling we are down to a geometric mean 0.1%
      increase in allocation (in perf/compiler).  That seems fine.
      
      There is a big runtime improvement in T10359
      
      Metric Decrease:
          LargeRecord
          MultiLayerModulesTH_OneShot
          T13386
          T13719
      Metric Increase:
          T8095
      778c6adc
  21. Nov 01, 2022
    • Simon Peyton Jones's avatar
      Add accurate skolem info when quantifying · 0560821f
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      Ticket #22379 revealed that skolemiseQuantifiedTyVar was
      dropping the passed-in skol_info on the floor when it encountered
      a SkolemTv.  Bad!  Several TyCons thereby share a single SkolemInfo
      on their binders, which lead to bogus error reports.
      0560821f
  22. Oct 26, 2022
  23. Oct 13, 2022
  24. Sep 13, 2022
    • sheaf's avatar
      Diagnostic codes: acccept test changes · 362cca13
      sheaf authored and Marge Bot's avatar Marge Bot committed
      The testsuite output now contains diagnostic codes, so many tests need
      to be updated at once.
      We decided it was best to keep the diagnostic codes in the testsuite
      output, so that contributors don't inadvertently make changes to the
      diagnostic codes.
      362cca13
  25. Aug 19, 2022
  26. Jun 27, 2022
  27. Jun 06, 2022
  28. Apr 01, 2022
  29. Mar 15, 2022
    • Vladislav Zavialov's avatar
      Export (~) from Data.Type.Equality (#18862) · ab618309
      Vladislav Zavialov authored
      * Users can define their own (~) type operator
      * Haddock can display documentation for the built-in (~)
      * New transitional warnings implemented:
          -Wtype-equality-out-of-scope
          -Wtype-equality-requires-operators
      
      Updates the haddock submodule.
      ab618309
  30. Feb 23, 2022
    • Richard Eisenberg's avatar
      Kill derived constraints · a599abba
      Richard Eisenberg authored and Marge Bot's avatar Marge Bot committed
      Co-authored by: Sam Derbyshire
      
      Previously, GHC had three flavours of constraint:
      Wanted, Given, and Derived. This removes Derived constraints.
      
      Though serving a number of purposes, the most important role
      of Derived constraints was to enable better error messages.
      This job has been taken over by the new RewriterSets, as explained
      in Note [Wanteds rewrite wanteds] in GHC.Tc.Types.Constraint.
      
      Other knock-on effects:
       - Various new Notes as I learned about under-described bits of GHC
      
       - A reshuffling around the AST for implicit-parameter bindings,
         with better integration with TTG.
      
       - Various improvements around fundeps. These were caused by the
         fact that, previously, fundep constraints were all Derived,
         and Derived constraints would get dropped. Thus, an unsolved
         Derived didn't stop compilation. Without Derived, this is no
         longer possible, and so we have to be considerably more careful
         around fundeps.
      
       - A nice little refactoring in GHC.Tc.Errors to center the work
         on a new datatype called ErrorItem. Constraints are converted
         into ErrorItems at the start of processing, and this allows for
         a little preprocessing before the main classification.
      
       - This commit also cleans up the behavior in generalisation around
         functional dependencies. Now, if a variable is determined by
         functional dependencies, it will not be quantified. This change
         is user facing, but it should trim down GHC's strange behavior
         around fundeps.
      
       - Previously, reportWanteds did quite a bit of work, even on an empty
         WantedConstraints. This commit adds a fast path.
      
       - Now, GHC will unconditionally re-simplify constraints during
         quantification. See Note [Unconditionally resimplify constraints when
         quantifying], in GHC.Tc.Solver.
      
      Close #18398.
      Close #18406.
      Solve the fundep-related non-confluence in #18851.
      Close #19131.
      Close #19137.
      Close #20922.
      Close #20668.
      Close #19665.
      
      -------------------------
      Metric Decrease:
          LargeRecord
          T9872b
          T9872b_defer
          T9872d
          TcPlugin_RewritePerf
      -------------------------
      a599abba
  31. Feb 06, 2022
  32. Jan 29, 2022
    • Matthew Pickering's avatar
      Rework the handling of SkolemInfo · 268efcc9
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      
      The main purpose of this patch is to attach a SkolemInfo directly to
      each SkolemTv. This fixes the large number of bugs which have
      accumulated over the years where we failed to report errors due to
      having "no skolem info" for particular type variables. Now the origin of
      each type varible is stored on the type variable we can always report
      accurately where it cames from.
      
      Fixes #20969 #20732 #20680 #19482 #20232 #19752 #10946
        #19760 #20063 #13499 #14040
      
      The main changes of this patch are:
      
      * SkolemTv now contains a SkolemInfo field which tells us how the
        SkolemTv was created. Used when reporting errors.
      
      * Enforce invariants relating the SkolemInfoAnon and level of an implication (ic_info, ic_tclvl)
        to the SkolemInfo and level of the type variables in ic_skols.
          * All ic_skols are TcTyVars -- Check is currently disabled
          * All ic_skols are SkolemTv
          * The tv_lvl of the ic_skols agrees with the ic_tclvl
          * The ic_info agrees with the SkolInfo of the implication.
      
        These invariants are checked by a debug compiler by
        checkImplicationInvariants.
      
      * Completely refactor kcCheckDeclHeader_sig which kept
        doing my head in. Plus, it wasn't right because it wasn't skolemising
        the binders as it decomposed the kind signature.
      
        The new story is described in Note [kcCheckDeclHeader_sig].  The code
        is considerably shorter than before (roughly 240 lines turns into 150
        lines).
      
        It still has the same awkward complexity around computing arity as
        before, but that is a language design issue.
        See Note [Arity inference in kcCheckDeclHeader_sig]
      
      * I added new type synonyms MonoTcTyCon and PolyTcTyCon, and used
        them to be clear which TcTyCons have "finished" kinds etc, and
        which are monomorphic. See Note [TcTyCon, MonoTcTyCon, and PolyTcTyCon]
      
      * I renamed etaExpandAlgTyCon to splitTyConKind, becuase that's a
        better name, and it is very useful in kcCheckDeclHeader_sig, where
        eta-expansion isn't an issue.
      
      * Kill off the nasty `ClassScopedTvEnv` entirely.
      
      Co-authored-by: default avatarSimon Peyton Jones <simon.peytonjones@gmail.com>
      268efcc9
  33. Jan 17, 2022
  34. Nov 20, 2021
    • sheaf's avatar
      Include "not more specific" info in overlap msg · 742d8b60
      sheaf authored and Marge Bot's avatar Marge Bot committed
        When instances overlap, we now include additional information
        about why we weren't able to select an instance: perhaps
        one instance overlapped another but was not strictly more specific,
        so we aren't able to directly choose it.
      
      Fixes #20542
      742d8b60
  35. Oct 17, 2021
    • sheaf's avatar
      Introduce Concrete# for representation polymorphism checks · 81740ce8
      sheaf authored and Marge Bot's avatar Marge Bot committed
      PHASE 1: we never rewrite Concrete# evidence.
      
      This patch migrates all the representation polymorphism checks to
      the typechecker, using a new constraint form
      
        Concrete# :: forall k. k -> TupleRep '[]
      
      Whenever a type `ty` must be representation-polymorphic
      (e.g. it is the type of an argument to a function), we emit a new
      `Concrete# ty` Wanted constraint. If this constraint goes
      unsolved, we report a representation-polymorphism error to the user.
      The 'FRROrigin' datatype keeps track of the context of the
      representation-polymorphism check, for more informative error messages.
      
      This paves the way for further improvements, such as
      allowing type families in RuntimeReps and improving the soundness
      of typed Template Haskell. This is left as future work (PHASE 2).
      
      fixes #17907 #20277 #20330 #20423 #20426
      
      updates haddock submodule
      
      -------------------------
      Metric Decrease:
          T5642
      -------------------------
      81740ce8
  36. Oct 06, 2021
    • sheaf's avatar
      Improve overlap error for polykinded constraints · a466b024
      sheaf authored and Marge Bot's avatar Marge Bot committed
      There were two problems around `mkDictErr`:
      
        1. An outdated call to `flattenTys` meant that we missed out on some
           instances. As we no longer flatten type-family applications,
           the logic is obsolete and can be removed.
      
        2. We reported "out of scope" errors in a poly-kinded situation
           because `BoxedRep` and `Lifted` were considered out of scope.
           We fix this by using `pretendNameIsInScope`.
      
      fixes #20465
      a466b024
  37. Sep 01, 2021
    • Hai Nguyen Quang's avatar
      Convert diagnostics in GHC.Tc.Validity to proper TcRnMessage. · af41496f
      Hai Nguyen Quang authored
      - Add 19 new messages. Update test outputs accordingly.
      
      - Pretty print suggest-extensions hints: remove space before
      interspersed commas.
      
      - Refactor Rank's MonoType constructors. Each MonoType constructor
      should represent a specific case. With the Doc suggestion belonging
      to the TcRnMessage diagnostics instead.
      
      - Move Rank from Validity to its own `GHC.Tc.Types.Rank` module.
      
      - Remove the outdated `check_irred_pred` check.
      
      - Remove the outdated duplication check in `check_valid_theta`, which
      was subsumed by `redundant-constraints`.
      
      - Add missing test cases for quantified-constraints/T16474 & th/T12387a.
      af41496f
  38. Jun 10, 2021
  39. May 20, 2021
    • Matthew Pickering's avatar
      Remove transitive information about modules and packages from interface files · 38faeea1
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      This commit modifies interface files so that *only* direct information
      about modules and packages is stored in the interface file.
      
      * Only direct module and direct package dependencies are stored in the
      interface files.
      * Trusted packages are now stored separately as they need to be checked
        transitively.
      * hs-boot files below the compiled module in the home module are stored
        so that eps_is_boot can be calculated in one-shot mode without loading
        all interface files in the home package.
      * The transitive closure of signatures is stored separately
      
      This is important for two reasons
      
      * Less recompilation is needed, as motivated by #16885, a lot of
      redundant compilation was triggered when adding new imports deep in the
      module tree as all the parent interface files had to be redundantly
      updated.
      * Checking an interface file is cheaper because you don't have to
      perform a transitive traversal to check the dependencies are up-to-date.
      
      In the code, places where we would have used the transitive closure, we
      instead compute the necessary transitive closure. The closure is not
      computed very often, was already happening in checkDependencies, and
      was already happening in getLinkDeps.
      
      Fixes #16885
      
      -------------------------
      Metric Decrease:
          MultiLayerModules
          T13701
          T13719
      -------------------------
      38faeea1
Loading