Skip to content
Snippets Groups Projects
  1. Jun 30, 2023
  2. Jun 21, 2023
  3. Jun 09, 2023
  4. 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
  5. May 15, 2023
    • sheaf's avatar
      Improve "ambiguous occurrence" error messages · 5ae81842
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This error was sometimes a bit confusing, especially when data families
      were involved. This commit improves the general presentation of the
      "ambiguous occurrence" error, and adds a bit of extra context in the
      case of data families.
      
      Fixes #23301
      5ae81842
  6. May 05, 2023
  7. Apr 30, 2023
  8. Apr 04, 2023
    • sheaf's avatar
      Relax assertion in varToRecFieldOcc · cd00e321
      sheaf authored and Marge Bot's avatar Marge Bot committed
      When using Template Haskell, it is possible to re-parent a field OccName
      belonging to one data constructor to another data constructor. The
      lsp-types package did this in order to "extend" a data constructor
      with additional fields.
      
      This ran into an assertion in 'varToRecFieldOcc'. This assertion
      can simply be relaxed, as the resulting splices are perfectly sound.
      
      Fixes #23220
      cd00e321
  9. 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
  10. Apr 01, 2023
  11. Mar 29, 2023
    • sheaf's avatar
      Handle records in the renamer · 3f374399
      sheaf authored
      This patch moves the field-based logic for disambiguating record updates
      to the renamer. The type-directed logic, scheduled for removal, remains
      in the typechecker.
      
      To do this properly (and fix the myriad of bugs surrounding the treatment
      of duplicate record fields), we took the following main steps:
      
        1. Create GREInfo, a renamer-level equivalent to TyThing which stores
           information pertinent to the renamer.
           This allows us to uniformly treat imported and local Names in the
           renamer, as described in Note [GREInfo].
      
        2. Remove GreName. Instead of a GlobalRdrElt storing GreNames, which
           distinguished between normal names and field names, we now store
           simple Names in GlobalRdrElt, along with the new GREInfo information
           which allows us to recover the FieldLabel for record fields.
      
        3. Add namespacing for record fields, within the OccNames themselves.
           This allows us to remove the mangling of duplicate field selectors.
      
           This change ensures we don't print mangled names to the user in
           error messages, and allows us to handle duplicate record fields
           in Template Haskell.
      
        4. Move record disambiguation to the renamer, and operate on the
           level of data constructors instead, to handle #21443.
      
           The error message text for ambiguous record updates has also been
           changed to reflect that type-directed disambiguation is on the way
           out.
      
      (3) means that OccEnv is now a bit more complex: we first key on the
      textual name, which gives an inner map keyed on NameSpace:
      
        OccEnv a ~ FastStringEnv (UniqFM NameSpace a)
      
      Note that this change, along with (2), both increase the memory residency
      of GlobalRdrEnv = OccEnv [GlobalRdrElt], which causes a few tests to
      regress somewhat in compile-time allocation.
      
      Even though (3) simplified a lot of code (in particular the treatment of
      field selectors within Template Haskell and in error messages), it came
      with one important wrinkle: in the situation of
      
        -- M.hs-boot
        module M where { data A; foo :: A -> Int }
        -- M.hs
        module M where { data A = MkA { foo :: Int } }
      
      we have that M.hs-boot exports a variable foo, which is supposed to match
      with the record field foo that M exports. To solve this issue, we add a
      new impedance-matching binding to M
      
        foo{var} = foo{fld}
      
      This mimics the logic that existed already for impedance-binding DFunIds,
      but getting it right was a bit tricky.
      See Note [Record field impedance matching] in GHC.Tc.Module.
      
      We also needed to be careful to avoid introducing space leaks in GHCi.
      So we dehydrate the GlobalRdrEnv before storing it anywhere, e.g. in
      ModIface. This means stubbing out all the GREInfo fields, with the
      function forceGlobalRdrEnv.
      When we read it back in, we rehydrate with rehydrateGlobalRdrEnv.
      This robustly avoids any space leaks caused by retaining old type
      environments.
      
      Fixes #13352 #14848 #17381 #17551 #19664 #21443 #21444 #21720 #21898 #21946 #21959 #22125 #22160 #23010 #23062 #23063
      
      Updates haddock submodule
      
      -------------------------
      Metric Increase:
          MultiComponentModules
          MultiLayerModules
          MultiLayerModulesDefsGhci
          MultiLayerModulesNoCode
          T13701
          T14697
          hard_hole_fits
      -------------------------
      3f374399
  12. Feb 07, 2023
    • sheaf's avatar
      Don't allow . in overloaded labels · b17fb3d9
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This patch removes . from the list of allowed characters in a non-quoted
      overloaded label, as it was realised this steals syntax, e.g. (#.).
      
      Users who want this functionality will have to add quotes around the
      label, e.g. `#"17.28"`.
      
      Fixes #22821
      b17fb3d9
  13. Oct 26, 2022
  14. Oct 12, 2022
  15. Sep 13, 2022
    • Adam Gundry's avatar
      Allow imports to reference multiple fields with the same name (#21625) · 08f6730c
      Adam Gundry authored and Marge Bot's avatar Marge Bot committed
      If a module `M` exports two fields `f` (using DuplicateRecordFields), we can
      still accept
      
          import M (f)
          import M hiding (f)
      
      and treat `f` as referencing both of them.  This was accepted in GHC 9.0, but gave
      rise to an ambiguity error in GHC 9.2.  See #21625.
      
      This patch also documents this behaviour in the user's guide, and updates the
      test for #16745 which is now treated differently.
      08f6730c
    • 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
  16. Aug 19, 2022
  17. May 17, 2022
  18. Feb 08, 2022
    • sheaf's avatar
      Allow HasField in quantified constraints · a9355e84
      sheaf authored and Marge Bot's avatar Marge Bot committed
      We perform validity checking on user-written HasField instances,
      for example to disallow:
      
        data Foo a = Foo { fld :: Int }
        instance HasField "fld" (Foo a) Bool
      
      However, these checks were also being made on quantified constraints,
      e.g.
      
        data Bar where
          Bar :: (forall a. HasField s (Foo a) Int) => Proxy s -> Bar
      
      This patch simply skips validity checking for quantified constraints,
      in line with what we already do for equality constraints such as
      Coercible.
      
      Fixes #20989
      a9355e84
  19. Feb 05, 2022
    • Simon Peyton Jones's avatar
      Improve errors for non-existent labels · 6af8e71e
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      This patch fixes #17469, by improving matters when you use
      non-existent field names in a record construction:
         data T = MkT { x :: Int }
         f v = MkT { y = 3 }
      
      The check is now made in the renamer, in GHC.Rename.Env.lookupRecFieldOcc.
      
      That in turn led to a spurious error in T9975a, which is fixed by
      making GHC.Rename.Names.extendGlobalRdrEnvRn fail fast if it finds
      duplicate bindings.  See Note [Fail fast on duplicate definitions]
      in that module for more details.
      
      This patch was originated and worked on by Alex D (@nineonine)
      6af8e71e
  20. Jan 17, 2022
  21. 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
  22. Nov 26, 2021
  23. May 22, 2021
    • Shayne Fletcher's avatar
      Change representation of field selector occurences · 0b1eed74
      Shayne Fletcher authored
      - Change the names of the fields in in `data FieldOcc`
      - Renames `HsRecFld` to `HsRecSel`
      - Replace `AmbiguousFieldOcc p` in `HsRecSel` with `FieldOcc p`
      - Contains a haddock submodule update
      
      The primary motivation of this change is to remove
      `AmbiguousFieldOcc`. This is one of a suite of changes improving how
      record syntax (most notably record update syntax) is represented in
      the AST.
      0b1eed74
    • Alex D's avatar
      Add regression test for #19287 · ef4d2999
      Alex D authored and Marge Bot's avatar Marge Bot committed
      ef4d2999
  24. Mar 29, 2021
    • Alfredo Di Napoli's avatar
      Add `MessageClass`, rework `Severity` and add `DiagnosticReason`. · c30af951
      Alfredo Di Napoli authored
      Other than that:
      
      * Fix T16167,json,json2,T7478,T10637 tests to reflect the introduction of
        the `MessageClass` type
      
      * Remove `makeIntoWarning`
      
      * Remove `warningsToMessages`
      
      * Refactor GHC.Tc.Errors
      
        1. Refactors GHC.Tc.Errors so that we use `DiagnosticReason` for "choices"
           (defer types errors, holes, etc);
      
        2. We get rid of `reportWarning` and `reportError` in favour of a general
           `reportDiagnostic`.
      
      * Introduce `DiagnosticReason`, `Severity` is an enum: This big commit makes
        `Severity` a simple enumeration, and introduces the concept of `DiagnosticReason`,
        which classifies the /reason/ why we are emitting a particular diagnostic.
        It also adds a monomorphic `DiagnosticMessage` type which is used for
        generic messages.
      
      * The `Severity` is computed (for now) from the reason, statically.
        Later improvement will add a `diagReasonSeverity` function to compute
        the `Severity` taking `DynFlags` into account.
      
      * Rename `logWarnings` into `logDiagnostics`
      
      * Add note and expand description of the `mkHoleError` function
      c30af951
  25. Mar 10, 2021
  26. Feb 26, 2021
  27. Feb 19, 2021
    • Simon Peyton Jones's avatar
      Improve handling of overloaded labels, literals, lists etc · 4196969c
      Simon Peyton Jones authored
      When implementing Quick Look I'd failed to remember that overloaded
      labels, like #foo, should be treated as a "head", so that they can be
      instantiated with Visible Type Application. This caused #19154.
      
      A very similar ticket covers overloaded literals: #19167.
      
      This patch fixes both problems, but (annoyingly, albeit temporarily)
      in two different ways.
      
      Overloaded labels
      
      I dealt with overloaded labels by buying fully into the
      Rebindable Syntax approach described in GHC.Hs.Expr
      Note [Rebindable syntax and HsExpansion].
      
      There is a good overview in GHC.Rename.Expr
      Note [Handling overloaded and rebindable constructs].
      That module contains much of the payload for this patch.
      
      Specifically:
      
      * Overloaded labels are expanded in the renamer, fixing #19154.
        See Note [Overloaded labels] in GHC.Rename.Expr.
      
      * Left and right sections used to have special code paths in the
        typechecker and desugarer.  Now we just expand them in the
        renamer. This is harder than it sounds.  See GHC.Rename.Expr
        Note [Left and right sections].
      
      * Infix operator applications are expanded in the typechecker,
        specifically in GHC.Tc.Gen.App.splitHsApps.  See
        Note [Desugar OpApp in the typechecker] in that module
      
      * ExplicitLists are expanded in the renamer, when (and only when)
        OverloadedLists is on.
      
      * HsIf is expanded in the renamer when (and only when) RebindableSyntax
        is on.  Reason: the coverage checker treats HsIf specially.  Maybe
        we could instead expand it unconditionally, and fix up the coverage
        checker, but I did not attempt that.
      
      Overloaded literals
      
      Overloaded literals, like numbers (3, 4.2) and strings with
      OverloadedStrings, were not working correctly with explicit type
      applications (see #19167).  Ideally I'd also expand them in the
      renamer, like the stuff above, but I drew back on that because they
      can occur in HsPat as well, and I did not want to to do the HsExpanded
      thing for patterns.
      
      But they *can* now be the "head" of an application in the typechecker,
      and hence something like ("foo" @T) works now.  See
      GHC.Tc.Gen.Head.tcInferOverLit.  It's also done a bit more elegantly,
      rather than by constructing a new HsExpr and re-invoking the
      typechecker. There is some refactoring around tcShortCutLit.
      
      Ultimately there is more to do here, following the Rebindable Syntax
      story.
      
      There are a lot of knock-on effects:
      
      * HsOverLabel and ExplicitList no longer need funny (Maybe SyntaxExpr)
        fields to support rebindable syntax -- good!
      
      * HsOverLabel, OpApp, SectionL, SectionR all become impossible in the
        output of the typecheker, GhcTc; so we set their extension fields to
        Void. See GHC.Hs.Expr Note [Constructor cannot occur]
      
      * Template Haskell quotes for HsExpanded is a bit tricky.  See
        Note [Quotation and rebindable syntax] in GHC.HsToCore.Quote.
      
      * In GHC.HsToCore.Match.viewLExprEq, which groups equal HsExprs for the
        purpose of pattern-match overlap checking, I found that dictionary
        evidence for the same type could have two different names.  Easily
        fixed by comparing types not names.
      
      * I did quite a bit of annoying fiddling around in GHC.Tc.Gen.Head and
        GHC.Tc.Gen.App to get error message locations and contexts right,
        esp in splitHsApps, and the HsExprArg type.  Tiresome and not very
        illuminating.  But at least the tricky, higher order, Rebuilder
        function is gone.
      
      * Some refactoring in GHC.Tc.Utils.Monad around contexts and locations
        for rebindable syntax.
      
      * Incidentally fixes #19346, because we now print renamed, rather than
        typechecked, syntax in error mesages about applications.
      
      The commit removes the vestigial module GHC.Builtin.RebindableNames,
      and thus triggers a 2.4% metric decrease for test MultiLayerModules
      (#19293).
      
      Metric Decrease:
          MultiLayerModules
          T12545
      4196969c
  28. Feb 16, 2021
    • Adam Gundry's avatar
      Make sure HasField use counts for -Wunused-top-binds · 1109896c
      Adam Gundry authored and Marge Bot's avatar Marge Bot committed
      This is a small fix that depends on the previous commit, because it
      corrected the rnExpr free variable calculation for HsVars which refer
      to ambiguous fields. Fixes #19213.
      1109896c
    • Adam Gundry's avatar
      Implement NoFieldSelectors extension (ghc-proposals 160) · 2521b041
      Adam Gundry authored and Marge Bot's avatar Marge Bot committed
      
      Fixes #5972. This adds an extension NoFieldSelectors to disable the generation
      of selector functions corresponding to record fields.  When this extension is
      enabled, record field selectors are not accessible as functions, but users are
      still able to use them for record construction, pattern matching and updates.
      See Note [NoFieldSelectors] in GHC.Rename.Env for details.
      
      Defining the same field multiple times requires the DuplicateRecordFields
      extension to be enabled, even when NoFieldSelectors is in use.
      
      Along the way, this fixes the use of non-imported DuplicateRecordFields in GHCi
      with -fimplicit-import-qualified (fixes #18729).
      
      Moreover, it extends DisambiguateRecordFields to ignore non-fields when looking
      up fields in record updates (fixes #18999), as described by
      Note [DisambiguateRecordFields for updates].
      
      Co-authored-by: default avatarSimon Hafner <hafnersimon@gmail.com>
      Co-authored-by: default avatarFumiaki Kinoshita <fumiexcel@gmail.com>
      2521b041
  29. Jan 27, 2021
  30. Jan 22, 2021
    • Alfredo Di Napoli's avatar
      Fix tests relying on same-line diagnostic ordering · c36a4f63
      Alfredo Di Napoli authored and Marge Bot's avatar Marge Bot committed
      This commit fixes 19 tests which were failing due to the use of
      `consBag` / `snocBag`, which have been now replaced by `addMessage`.
      This means that now GHC would output things in different order but
      only for /diagnostics on the same line/, so this is just reflecting
      that. The "normal" order of messages is still guaranteed.
      c36a4f63
  31. Dec 24, 2020
    • Adam Gundry's avatar
      Refactor renamer datastructures · 6f8bafb4
      Adam Gundry authored and Marge Bot's avatar Marge Bot committed
      This patch significantly refactors key renamer datastructures (primarily Avail
      and GlobalRdrElt) in order to treat DuplicateRecordFields in a more robust way.
      In particular it allows the extension to be used with pattern synonyms (fixes
      where mangled record selector names could be printed instead of field labels
      (e.g. with -Wpartial-fields or hole fits, see new tests).
      
      The key idea is the introduction of a new type GreName for names that may
      represent either normal entities or field labels.  This is then used in
      GlobalRdrElt and AvailInfo, in place of the old way of representing fields
      using FldParent (yuck) and an extra list in AvailTC.
      
      Updates the haddock submodule.
      6f8bafb4
  32. Sep 24, 2020
    • Simon Peyton Jones's avatar
      Improve kind generalisation, error messages · 9fa26aa1
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      This patch does two things:
      
      * It refactors GHC.Tc.Errors a bit.  In debugging Quick Look I was
        forced to look in detail at error messages, and ended up doing a bit
        of refactoring, esp in mkTyVarEqErr'.  It's still quite a mess, but
        a bit better, I think.
      
      * It makes a significant improvement to the kind checking of type and
        class declarations. Specifically, we now ensure that if kind
        checking fails with an unsolved constraint, all the skolems are in
        scope.  That wasn't the case before, which led to some obscure error
        messages; and occasional failures with "no skolem info" (eg #16245).
      
      Both of these, and the main Quick Look patch itself, affect a /lot/ of
      error messages, as you can see from the number of files changed.  I've
      checked them all; I think they are as good or better than before.
      
      Smaller things
      
      * I documented the various instances of VarBndr better.
        See Note [The VarBndr tyep and its uses] in GHC.Types.Var
      
      * Renamed GHC.Tc.Solver.simpl_top to simplifyTopWanteds
      
      * A bit of refactoring in bindExplicitTKTele, to avoid the
        footwork with Either.  Simpler now.
      
      * Move promoteTyVar from GHC.Tc.Solver to GHC.Tc.Utils.TcMType
      
      Fixes #16245 (comment 211369), memorialised as
        typecheck/polykinds/T16245a
      Also fixes the three bugs in #18640
      9fa26aa1
  33. May 08, 2020
  34. Apr 23, 2020
    • Simon Peyton Jones's avatar
      Do eager instantation in terms · ffde2348
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      This patch implements eager instantiation, a small but critical change
      to the type inference engine, #17173.  The main change is this:
      
        When inferring types, always return an instantiated type
        (for now, deeply instantiated; in future shallowly instantiated)
      
      There is more discussion in
      https://www.tweag.io/posts/2020-04-02-lazy-eager-instantiation.html
      
      There is quite a bit of refactoring in this patch:
      
      * The ir_inst field of GHC.Tc.Utils.TcType.InferResultk
        has entirely gone.  So tcInferInst and tcInferNoInst have collapsed
        into tcInfer.
      
      * Type inference of applications, via tcInferApp and
        tcInferAppHead, are substantially refactored, preparing
        the way for Quick Look impredicativity.
      
      * New pure function GHC.Tc.Gen.Expr.collectHsArgs and applyHsArgs
        are beatifully dual.  We can see the zipper!
      
      * GHC.Tc.Gen.Expr.tcArgs is now much nicer; no longer needs to return
        a wrapper
      
      * In HsExpr, HsTypeApp now contains the the actual type argument,
        and is used in desugaring, rather than putting it in a mysterious
        wrapper.
      
      * I struggled a bit with good error reporting in
        Unify.matchActualFunTysPart. It's a little bit simpler than before,
        but still not great.
      
      Some smaller things
      
      * Rename tcPolyExpr --> tcCheckExpr
               tcMonoExpr --> tcLExpr
      * tcPatSig moves from GHC.Tc.Gen.HsType to GHC.Tc.Gen.Pat
      
      Metric Decrease:
          T9961
      
      Reduction of 1.6% in comiler allocation on T9961, I think.
      ffde2348
  35. Jan 13, 2020
    • Matthew Pickering's avatar
      Overloaded Quotation Brackets (#246) · 9129210f
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      This patch implements overloaded quotation brackets which generalise the
      desugaring of all quotation forms in terms of a new minimal interface.
      
      The main change is that a quotation, for example, [e| 5 |], will now
      have type `Quote m => m Exp` rather than `Q Exp`. The `Quote` typeclass
      contains a single method for generating new names which is used when
      desugaring binding structures.
      
      The return type of functions from the `Lift` type class, `lift` and `liftTyped` have
      been restricted to `forall m . Quote m => m Exp` rather than returning a
      result in a Q monad.
      
      More details about the feature can be read in the GHC proposal.
      
      https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0246-overloaded-bracket.rst
      9129210f
  36. Nov 27, 2019
    • Vladislav Zavialov's avatar
      Whitespace-sensitive bang patterns (#1087, #17162) · 8168b42a
      Vladislav Zavialov authored
      This patch implements a part of GHC Proposal #229 that covers five
      operators:
      
      * the bang operator (!)
      * the tilde operator (~)
      * the at operator (@)
      * the dollar operator ($)
      * the double dollar operator ($$)
      
      Based on surrounding whitespace, these operators are disambiguated into
      bang patterns, lazy patterns, strictness annotations, type
      applications, splices, and typed splices.
      
      This patch doesn't cover the (-) operator or the -Woperator-whitespace
      warning, which are left as future work.
      8168b42a
Loading