Skip to content
Snippets Groups Projects
  1. May 23, 2023
    • Simon Peyton Jones's avatar
      Add the SolverStage monad · e1590ddc
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      This refactoring makes a substantial improvement in the
      structure of the type-checker's constraint solver: #23070.
      
      Specifically:
      
      * Introduced the SolverStage monad.   See GHC.Tc.Solver.Monad
        Note [The SolverStage monad]
      
      * Make each solver pipeline (equalities, dictionaries, irreds etc)
        deal with updating the inert set, as a separate SolverStage.  There
        is sometimes special stuff to do, and it means that each full
        pipeline can have type SolverStage Void, indicating that they never
        return anything.
      
      * Made GHC.Tc.Solver.Equality.zonkEqTypes into a SolverStage.  Much nicer.
      
      * Combined the remnants of GHC.Tc.Solver.Canonical and
        GHC.Tc.Solver.Interact into a new module GHC.Tc.Solver.Solve.
        (Interact and Canonical are removed.)
      
      * Gave the same treatment to dictionary and irred constraints
        as I have already done for equality constraints:
          * New types (akin to EqCt): IrredCt and DictCt
          * Ct is now just a simple sum type
                data Ct
                  = CDictCan      DictCt
                  | CIrredCan     IrredCt
                  | CEqCan        EqCt
                  | CQuantCan     QCInst
                  | CNonCanonical CtEvidence
          * inert_dicts can now have the better type DictMap DictCt, instead of
            DictMap Ct; and similarly inert_irreds.
      
      * Significantly simplified the treatment of implicit parameters.
        Previously we had a number of special cases
          * interactGivenIP, an entire function
          * special case in maybeKickOut
          * special case in findDict, when looking up dictionaries
        But actually it's simpler than that. When adding a new Given, implicit
        parameter constraint to the InertSet, we just need to kick out any
        existing inert constraints that mention that implicit parameter.
      
        The main work is done in GHC.Tc.Solver.InertSet.delIPDict, along with
        its auxiliary GHC.Core.Predicate.mentionsIP.
      
        See Note [Shadowing of implicit parameters] in GHC.Tc.Solver.Dict.
      
      * Add a new fast-path in GHC.Tc.Errors.Hole.tcCheckHoleFit.
        See Note [Fast path for tcCheckHoleFit].  This is a big win in some cases:
        test hard_hole_fits gets nearly 40% faster (at compile time).
      
      * Add a new fast-path for solving /boxed/ equality constraints
        (t1 ~ t2).  See Note [Solving equality classes] in GHC.Tc.Solver.Dict.
        This makes a big difference too: test T17836 compiles 40% faster.
      
      * Implement the PermissivePlan of #23413, which concerns what happens with
        insoluble Givens.   Our previous treatment was wildly inconsistent as that
        ticket pointed out.
      
        A part of this, I simplified GHC.Tc.Validity.checkAmbiguity: now we simply
        don't run the ambiguity check at all if -XAllowAmbiguousTypes is on.
      
      Smaller points:
      
      * In `GHC.Tc.Errors.misMatchOrCND` instead of having a special case for
        insoluble /occurs/ checks, broaden in to all insouluble constraints.
        Just generally better. See Note [Insoluble mis-match] in that module.
      
      As noted above, compile time perf gets better.  Here are the changes
      over 0.5% on Fedora.  (The figures are slightly larger on Windows for
      some reason.)
      
      Metrics: compile_time/bytes allocated
      -------------------------------------
                      LargeRecord(normal)   -0.9%
      MultiLayerModulesTH_OneShot(normal)   +0.5%
                           T11822(normal)   -0.6%
                           T12227(normal)   -1.8% GOOD
                           T12545(normal)   -0.5%
                           T13035(normal)   -0.6%
                           T15703(normal)   -1.4% GOOD
                           T16875(normal)   -0.5%
                           T17836(normal)  -40.7% GOOD
                          T17836b(normal)  -12.3% GOOD
                          T17977b(normal)   -0.5%
                            T5837(normal)   -1.1%
                            T8095(normal)   -2.7% GOOD
                            T9020(optasm)   -1.1%
                   hard_hole_fits(normal)  -37.0% GOOD
      
                                geo. mean   -1.3%
                                minimum    -40.7%
                                maximum     +0.5%
      
      Metric Decrease:
          T12227
          T15703
          T17836
          T17836b
          T8095
          hard_hole_fits
          LargeRecord
          T9198
          T13035
      e1590ddc
  2. Apr 27, 2023
    • Cheng Shao's avatar
      testsuite: add missing annotations for some tests · b174a110
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      This patch adds missing annotations (req_th, req_dynamic_lib_support,
      req_rts_linker) to some tests. They were discovered when testing
      wasm32, though it's better to be explicit about what features they
      require, rather than simply adding when(arch('wasm32'), skip).
      b174a110
  3. Nov 29, 2022
  4. 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
  5. 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
  6. 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
  7. Aug 19, 2022
  8. May 16, 2022
  9. 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
  10. 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
  11. Jan 12, 2022
    • sheaf's avatar
      TcPlugins: `newWanted` uses the provided `CtLoc` · 49731fed
      sheaf authored and Marge Bot's avatar Marge Bot committed
      The `GHC.Tc.Plugin.newWanted` function takes a `CtLoc` as an argument,
      but it used to discard the location information, keeping only
      the `CtOrigin`. It would then retrieve the source location from the
      `TcM` environment using `getCtLocM`.
      
      This patch changes this so that `GHC.Tc.Plugin.newWanted` passes on
      the full `CtLoc`. This means that authors of type-checking plugins
      no longer need to manually set the `CtLoc` environment in the `TcM`
      monad if they want to create a new Wanted constraint with the given
      `CtLoc` (in particular, for setting the `SrcSpan` of an emitted
      constraint). This makes the `newWanted` function consistent with
      `newGiven`, which always used the full `CtLoc` instead of using
      the environment.
      
      Fixes #20895
      49731fed
  12. Dec 28, 2021
    • Matthew Pickering's avatar
      Multiple Home Units · fd42ab5f
      Matthew Pickering authored
      
      Multiple home units allows you to load different packages which may depend on
      each other into one GHC session. This will allow both GHCi and HLS to support
      multi component projects more naturally.
      
      Public Interface
      ~~~~~~~~~~~~~~~~
      
      In order to specify multiple units, the -unit @⟨filename⟩ flag
      is given multiple times with a response file containing the arguments for each unit.
      The response file contains a newline separated list of arguments.
      
      ```
      ghc -unit @unitLibCore -unit @unitLib
      ```
      
      where the `unitLibCore` response file contains the normal arguments that cabal would pass to `--make` mode.
      
      ```
      -this-unit-id lib-core-0.1.0.0
      -i
      -isrc
      LibCore.Utils
      LibCore.Types
      ```
      
      The response file for lib, can specify a dependency on lib-core, so then modules in lib can use modules from lib-core.
      
      ```
      -this-unit-id lib-0.1.0.0
      -package-id lib-core-0.1.0.0
      -i
      -isrc
      Lib.Parse
      Lib.Render
      ```
      
      Then when the compiler starts in --make mode it will compile both units lib and lib-core.
      
      There is also very basic support for multiple home units in GHCi, at the
      moment you can start a GHCi session with multiple units but only the
      :reload is supported. Most commands in GHCi assume a single home unit,
      and so it is additional work to work out how to modify the interface to
      support multiple loaded home units.
      
      Options used when working with Multiple Home Units
      
      There are a few extra flags which have been introduced specifically for
      working with multiple home units. The flags allow a home unit to pretend
      it’s more like an installed package, for example, specifying the package
      name, module visibility and reexported modules.
      
      -working-dir ⟨dir⟩
      
          It is common to assume that a package is compiled in the directory
          where its cabal file resides. Thus, all paths used in the compiler
          are assumed to be relative to this directory. When there are
          multiple home units the compiler is often not operating in the
          standard directory and instead where the cabal.project file is
          located. In this case the -working-dir option can be passed which
          specifies the path from the current directory to the directory the
          unit assumes to be it’s root, normally the directory which contains
          the cabal file.
      
          When the flag is passed, any relative paths used by the compiler are
          offset by the working directory. Notably this includes -i and
          -I⟨dir⟩ flags.
      
      -this-package-name ⟨name⟩
      
          This flag papers over the awkward interaction of the PackageImports
          and multiple home units. When using PackageImports you can specify
          the name of the package in an import to disambiguate between modules
          which appear in multiple packages with the same name.
      
          This flag allows a home unit to be given a package name so that you
          can also disambiguate between multiple home units which provide
          modules with the same name.
      
      -hidden-module ⟨module name⟩
      
          This flag can be supplied multiple times in order to specify which
          modules in a home unit should not be visible outside of the unit it
          belongs to.
      
          The main use of this flag is to be able to recreate the difference
          between an exposed and hidden module for installed packages.
      
      -reexported-module ⟨module name⟩
      
          This flag can be supplied multiple times in order to specify which
          modules are not defined in a unit but should be reexported. The
          effect is that other units will see this module as if it was defined
          in this unit.
      
          The use of this flag is to be able to replicate the reexported
          modules feature of packages with multiple home units.
      
      Offsetting Paths in Template Haskell splices
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      When using Template Haskell to embed files into your program,
      traditionally the paths have been interpreted relative to the directory
      where the .cabal file resides. This causes problems for multiple home
      units as we are compiling many different libraries at once which have
      .cabal files in different directories.
      
      For this purpose we have introduced a way to query the value of the
      -working-dir flag to the Template Haskell API. By using this function we
      can implement a makeRelativeToProject function which offsets a path
      which is relative to the original project root by the value of
      -working-dir.
      
      ```
      import Language.Haskell.TH.Syntax ( makeRelativeToProject )
      
      foo = $(makeRelativeToProject "./relative/path" >>= embedFile)
      ```
      
      > If you write a relative path in a Template Haskell splice you should use the makeRelativeToProject function so that your library works correctly with multiple home units.
      
      A similar function already exists in the file-embed library. The
      function in template-haskell implements this function in a more robust
      manner by honouring the -working-dir flag rather than searching the file
      system.
      
      Closure Property for Home Units
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      For tools or libraries using the API there is one very important closure
      property which must be adhered to:
      
      > Any dependency which is not a home unit must not (transitively) depend
        on a home unit.
      
      For example, if you have three packages p, q and r, then if p depends on
      q which depends on r then it is illegal to load both p and r as home
      units but not q, because q is a dependency of the home unit p which
      depends on another home unit r.
      
      If you are using GHC by the command line then this property is checked,
      but if you are using the API then you need to check this property
      yourself. If you get it wrong you will probably get some very confusing
      errors about overlapping instances.
      
      Limitations of Multiple Home Units
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      There are a few limitations of the initial implementation which will be smoothed out on user demand.
      
          * Package thinning/renaming syntax is not supported
          * More complicated reexports/renaming are not yet supported.
          * It’s more common to run into existing linker bugs when loading a
            large number of packages in a session (for example #20674, #20689)
          * Backpack is not yet supported when using multiple home units.
          * Dependency chasing can be quite slow with a large number of
            modules and packages.
          * Loading wired-in packages as home units is currently not supported
            (this only really affects GHC developers attempting to load
            template-haskell).
          * Barely any normal GHCi features are supported, it would be good to
            support enough for ghcid to work correctly.
      
      Despite these limitations, the implementation works already for nearly
      all packages. It has been testing on large dependency closures,
      including the whole of head.hackage which is a total of 4784 modules
      from 452 packages.
      
      Internal Changes
      ~~~~~~~~~~~~~~~~
      
      * The biggest change is that the HomePackageTable is replaced with the
        HomeUnitGraph. The HomeUnitGraph is a map from UnitId to HomeUnitEnv,
        which contains information specific to each home unit.
      * The HomeUnitEnv contains:
          - A unit state, each home unit can have different package db flags
          - A set of dynflags, each home unit can have different flags
          - A HomePackageTable
      * LinkNode: A new node type is added to the ModuleGraph, this is used to
        place the linking step into the build plan so linking can proceed in
        parralel with other packages being built.
      * New invariant: Dependencies of a ModuleGraphNode can be completely
        determined by looking at the value of the node. In order to achieve
        this, downsweep now performs a more complete job of downsweeping and
        then the dependenices are recorded forever in the node rather than
        being computed again from the ModSummary.
      * Some transitive module calculations are rewritten to use the
        ModuleGraph which is more efficient.
      * There is always an active home unit, which simplifies modifying a lot
        of the existing API code which is unit agnostic (for example, in the
        driver).
      
      The road may be bumpy for a little while after this change but the
      basics are well-tested.
      
      One small metric increase, which we accept and also submodule update to
      haddock which removes ExtendedModSummary.
      
      Closes #10827
      
      -------------------------
      Metric Increase:
          MultiLayerModules
      -------------------------
      
      Co-authored-by: default avatarFendor <power.walross@gmail.com>
      fd42ab5f
  13. Oct 22, 2021
    • Sylvain Henry's avatar
      Refactor package imports · 806e49ae
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      Use an (Raw)PkgQual datatype instead of `Maybe FastString` to represent
      package imports. Factorize the code that renames RawPkgQual into PkgQual
      in function `rnPkgQual`. Renaming consists in checking if the FastString
      is the magic "this" keyword, the home-unit unit-id or something else.
      
      Bump haddock submodule
      806e49ae
  14. Sep 11, 2021
    • Sylvain Henry's avatar
      Canonicalize bignum literals · 089de88e
      Sylvain Henry authored and Marge Bot's avatar Marge Bot committed
      Before this patch Integer and Natural literals were desugared into "real"
      Core in Core prep. Now we desugar them directly into their final ConApp
      form in HsToCore. We only keep the double representation for BigNat#
      (literals larger than a machine Word/Int) which are still desugared in
      Core prep.
      
      Using the final form directly allows case-of-known-constructor to fire
      for bignum literals, fixing #20245.
      
      Slight increase (+2.3) in T4801 which is a pathological case with
      Integer literals.
      
      Metric Increase:
          T4801
          T11545
      089de88e
  15. Aug 15, 2021
    • sheaf's avatar
      Update TcPlugin_RewritePerf performance test · 71130bf8
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This test exhibited inconsistent behaviour, with different CI runs
      having a 98% decrease in allocations.
      This commit addresses this problem by ensuring that we measure
      allocations of the whole collection of modules used in the test.
      
      -------------------------
      Metric Increase:
          TcPlugin_RewritePerf
      -------------------------
      71130bf8
  16. Aug 13, 2021
    • sheaf's avatar
      Add rewriting to typechecking plugins · 9d4ba36f
      sheaf authored
      Type-checking plugins can now directly rewrite type-families.
      The TcPlugin record is given a new field, tcPluginRewrite.
      The plugin specifies how to rewrite certain type-families with a value
      of type `UniqFM TyCon TcPluginRewriter`, where:
      
      type TcPluginRewriter
        =  RewriteEnv -- Rewriter environment
        -> [Ct]       -- Givens
        -> [TcType]   -- type family arguments
        -> TcPluginM TcPluginRewriteResult
      
      data TcPluginRewriteResult
        = TcPluginNoRewrite
        | TcPluginRewriteTo
            { tcPluginRewriteTo    :: Reduction
            , tcRewriterNewWanteds :: [Ct]
            }
      
      When rewriting an exactly-saturated type-family application,
      GHC will first query type-checking plugins for possible rewritings
      before proceeding.
      
      Includes some changes to the TcPlugin API, e.g. removal
      of the EvBindsVar parameter to the TcPluginM monad.
      9d4ba36f
  17. Jul 24, 2021
    • sheaf's avatar
      Add nontrivial type-checking plugin tests · ba302877
      sheaf authored and Marge Bot's avatar Marge Bot committed
        Three new tests for type-checking plugins:
      
          - TcPlugin_Nullary, solving a nullary class constraint
          - TcPlugin_Args, providing evidence for a (unary) class constraint
            using arguments supplied to the plugin
          - TcPlugin_TyFam, solving an equality constraint to rewrite
            a type-family application
      
        More extensive descriptions of the plugins can be found in their
        respective defining modules.
      ba302877
Loading