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. Jul 03, 2023
  3. 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
    • Andrei Borzenkov's avatar
      Implement the -Wimplicit-rhs-quantification warning (#23510) · a71b60e9
      Andrei Borzenkov authored and Marge Bot's avatar Marge Bot committed
      GHC Proposal #425 "Invisible binders in type declarations" forbids
      implicit quantification of type variables that occur free on the
      right-hand side of a type synonym but are not mentioned on the left-hand side.
      The users are expected to rewrite this using invisible binders:
      
          type T1 :: forall a . Maybe a
          type T1    = 'Nothing :: Maybe a      -- old
          type T1 @a = 'Nothing :: Maybe a      -- new
      
      Since the @k-binders are a new feature, we need to wait for three releases
      before we require the use of the new syntax. In the meantime, we ought to
      provide users with a new warning, -Wimplicit-rhs-quantification, that would
      detect when such implicit quantification takes place, and include it in -Wcompat.
      a71b60e9
  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 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
  6. Apr 26, 2023
  7. Apr 14, 2023
    • Simon Peyton Jones's avatar
      Stop if type constructors have kind errors · d48fbfea
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      Otherwise we get knock-on errors, such as #23252.
      
      This makes GHC fail a bit sooner, and I have not attempted to add
      recovery code, to add a fake TyCon place of the erroneous one,
      in an attempt to get more type errors in one pass.  We could
      do that (perhaps) if there was a call for it.
      d48fbfea
  8. Apr 01, 2023
  9. Mar 22, 2023
  10. 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
  11. Nov 29, 2022
  12. 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
  13. 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
  14. Oct 26, 2022
    • Vladislav Zavialov's avatar
      Use TcRnVDQInTermType in noNestedForallsContextsErr (#20115) · f60a1a62
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      When faced with VDQ in the type of a term, GHC generates the following
      error message:
      
      	Illegal visible, dependent quantification in the type of a term
      	(GHC does not yet support this)
      
      Prior to this patch, there were two ways this message could have been
      generated and represented:
      
      	1. with the dedicated constructor TcRnVDQInTermType
      	    (see check_type in GHC.Tc.Validity)
      	2. with the transitional constructor TcRnUnknownMessage
      	    (see noNestedForallsContextsErr in GHC.Rename.Utils)
      
      Not only this led to duplication of code generating the final SDoc,
      it also made it tricky to track the origin of the error message.
      
      This patch fixes the problem by using TcRnVDQInTermType exclusively.
      f60a1a62
    • Sylvain Henry's avatar
      Testsuite: more precise test options · 9ab31f42
      Sylvain Henry authored
      Necessary for newer cross-compiling backends (JS, Wasm) that don't
      support TH yet.
      9ab31f42
  15. Oct 06, 2022
  16. 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
  17. Aug 19, 2022
  18. Jun 27, 2022
  19. Jun 06, 2022
  20. May 04, 2022
  21. Apr 01, 2022
  22. 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
  23. Feb 06, 2022
  24. 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
  25. Jan 17, 2022
  26. Dec 25, 2021
  27. Nov 17, 2021
    • Sebastian Graf's avatar
      Pmc: Don't case split on wildcard matches (#20642) · 29086749
      Sebastian Graf authored and Marge Bot's avatar Marge Bot committed
      Since 8.10, when formatting a pattern match warning, we'd case split on a
      wildcard match such as
      ```hs
      foo :: [a] -> [a]
      foo [] = []
      foo xs = ys
        where
        (_, ys@(_:_)) = splitAt 0 xs
      -- Pattern match(es) are non-exhaustive
      -- In a pattern binding:
      --     Patterns not matched:
      --         ([], [])
      --         ((_:_), [])
      ```
      But that's quite verbose and distracts from which part of the pattern was
      actually the inexhaustive one. We'd prefer a wildcard for the first pair
      component here, like it used to be in GHC 8.8.
      
      On the other hand, case splitting is pretty handy for `-XEmptyCase` to know the
      different constructors we could've matched on:
      ```hs
      f :: Bool -> ()
      f x = case x of {}
      -- Pattern match(es) are non-exhaustive
      -- In a pattern binding:
      --     Patterns not matched:
      --         False
      --         True
      ```
      The solution is to communicate that we want a top-level case split to
      `generateInhabitingPatterns` for `-XEmptyCase`, which is exactly what
      this patch arranges. Details in `Note [Case split inhabiting patterns]`.
      
      Fixes #20642.
      29086749
    • Ben Gamari's avatar
      Increase type sharing · 083a7583
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      Fixes #20541 by making mkTyConApp do more sharing of types.
      In particular, replace
      
      * BoxedRep Lifted    ==>  LiftedRep
      * BoxedRep Unlifted  ==>  UnliftedRep
      * TupleRep '[]       ==>  ZeroBitRep
      * TYPE ZeroBitRep    ==>  ZeroBitType
      
      In each case, the thing on the right is a type synonym
      for the thing on the left, declared in ghc-prim:GHC.Types.
      See Note [Using synonyms to compress types] in GHC.Core.Type.
      
      The synonyms for ZeroBitRep and ZeroBitType are new, but absolutely
      in the same spirit as the other ones.   (These synonyms are mainly
      for internal use, though the programmer can use them too.)
      
      I also renamed GHC.Core.Ty.Rep.isVoidTy to isZeroBitTy, to be
      compatible with the "zero-bit" nomenclature above.  See discussion
      on !6806.
      
      There is a tricky wrinkle: see GHC.Core.Types
        Note [Care using synonyms to compress types]
      
      Compiler allocation decreases by up to 0.8%.
      083a7583
  28. 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
  29. 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
  30. Jul 21, 2021
    • Alfredo Di Napoli's avatar
      Refactor SuggestExtension constructor in GhcHint · 06d1ca85
      Alfredo Di Napoli authored and Marge Bot's avatar Marge Bot committed
      This commit refactors the SuggestExtension type constructor of the
      GhcHint to be more powerful and flexible. In particular, we can now
      embed extra user information (essentially "sugar") to help clarifying
      the suggestion. This makes the following possible:
      
      Suggested fix: Perhaps you intended to use GADTs
                     or a similar language extension to enable syntax: data T where
      
      We can still give to IDEs and tools a `LangExt.Extension` they can use,
      but in the pretty-printed message we can tell the user a bit more on why
      such extension is needed.
      
      On top of that, we now have the ability to express conjuctions and
      disjunctons, for those cases where GHC suggests to enable "X or Y" and
      for the cases where we need "X and Y".
      06d1ca85
  31. Jun 10, 2021
  32. Jun 05, 2021
    • Richard Eisenberg's avatar
      Fix #19682 by breaking cycles in Deriveds · 8c90e6c7
      Richard Eisenberg authored and Marge Bot's avatar Marge Bot committed
      This commit expands the old Note [Type variable cycles in Givens] to apply
      as well to Deriveds. See the Note for details and examples. This fixes a
      regression introduced by my earlier commit that killed off the flattener in
      favor of the rewriter.
      
      A few other things happened along the way:
      
      * unifyTest was renamed to touchabilityTest, because that's what it does.
      
      * isInsolubleOccursCheck was folded into checkTypeEq, which does much of the
        same work. To get this to work out, though, we need to keep more careful
        track of what errors we spot in checkTypeEq, and so CheckTyEqResult has
        become rather more glorious.
      
      * A redundant Note or two was eliminated.
      
      * Kill off occCheckForErrors; due to Note [Rewriting synonyms], the
        extra occCheckExpand here is always redundant.
      
      * Store blocked equalities separately from other inerts; less stuff
        to look through when kicking out.
      
      Close #19682.
      
      test case: typecheck/should_compile/T19682{,b}
      8c90e6c7
  33. 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
  34. Mar 31, 2021
    • Simon Peyton Jones's avatar
      The result kind of a signature can't mention quantified vars · dbadd672
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      This patch fixes a small but egregious bug, which allowed
      a type signature like
          f :: forall a. blah
      not to fail if (blah :: a).  Acutally this only showed
      up as a ASSERT error (#19495).
      
      The fix is very short, but took quite a bit of head scratching
      
      Hence the long Note [Escaping kind in type signatures]
      
      While I was in town, I also added a short-cut for the
      common case of having no quantifiers to tcImplicitTKBndrsX.
      
      Metric Decrease:
          T9198
      
      Metric Increase:
          T9198
      dbadd672
  35. Mar 10, 2021
  36. Mar 07, 2021
    • Ben Gamari's avatar
      Implement BoxedRep proposal · 3e082f8f
      Ben Gamari authored
      This implements the BoxedRep proposal, refactoring the `RuntimeRep`
      hierarchy from:
      
      ```haskell
      data RuntimeRep = LiftedPtrRep | UnliftedPtrRep | ...
      ```
      
      to
      
      ```haskell
      data RuntimeRep = BoxedRep Levity | ...
      data Levity = Lifted | Unlifted
      ```
      
      Updates binary, haddock submodules.
      
      Closes #17526.
      
      Metric Increase:
          T12545
      3e082f8f
Loading