Skip to content
Snippets Groups Projects
  1. Feb 25, 2024
  2. Feb 08, 2024
    • Ben Gamari's avatar
      Move `base` to `ghc-internal` · 44f6557a
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      Here we move a good deal of the implementation of `base` into a new
      package, `ghc-internal` such that it can be evolved independently
      from the user-visible interfaces of `base`.
      
      While we want to isolate implementation from interfaces, naturally, we
      would like to avoid turning `base` into a mere set of module re-exports.
      However, this is a non-trivial undertaking for a variety of reasons:
      
       * `base` contains numerous known-key and wired-in things, requiring
         corresponding changes in the compiler
      
       * `base` contains a significant amount of C code and corresponding
         autoconf logic, which is very fragile and difficult to break apart
      
       * `base` has numerous import cycles, which are currently dealt with via
         carefully balanced `hs-boot` files
      
       * We must not break existing users
      
      To accomplish this migration, I tried the following approaches:
      
      * [Split-GHC.Base]: Break apart the GHC.Base knot to allow incremental
        migration of modules into ghc-internal: this knot is simply too
        intertwined to be easily pulled apart, especially given the rather
        tricky import cycles that it contains)
      
      * [Move-Core]: Moving the "core" connected component of base (roughly
        150 modules) into ghc-internal. While the Haskell side of this seems
        tractable, the C dependencies are very subtle to break apart.
      
      * [Move-Incrementally]:
      
        1. Move all of base into ghc-internal
        2. Examine the module structure and begin moving obvious modules (e.g.
           leaves of the import graph) back into base
        3. Examine the modules remaining in ghc-internal, refactor as necessary
           to facilitate further moves
        4. Go to (2) iterate until the cost/benefit of further moves is
           insufficient to justify continuing
        5. Rename the modules moved into ghc-internal to ensure that they don't
           overlap with those in base
        6. For each module moved into ghc-internal, add a shim module to base
           with the declarations which should be exposed and any requisite
           Haddocks (thus guaranteeing that base will be insulated from changes
           in the export lists of modules in ghc-internal
      
      Here I am using the [Move-Incrementally] approach, which is empirically
      the least painful of the unpleasant options above
      
      Bumps haddock submodule.
      
      Metric Decrease:
          haddock.Cabal
          haddock.base
      Metric Increase:
          MultiComponentModulesRecomp
          T16875
          size_hello_artifact
      44f6557a
  3. May 25, 2023
  4. Dec 24, 2022
    • Matthew Pickering's avatar
      Store RdrName rather than OccName in Holes · 6d62f6bf
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      In #20472 it was pointed out that you couldn't defer out of scope but
      the implementation collapsed a RdrName into an OccName to stuff it into
      a Hole. This leads to the error message for a deferred qualified name
      dropping the qualification which affects the quality of the error
      message.
      
      This commit adds a bit more structure to a hole, so a hole can replace a
      RdrName without losing information about what that RdrName was. This is
      important when printing error messages.
      
      I also added a test which checks the Template Haskell deferral of out of
      scope qualified names works properly.
      
      Fixes #22130
      6d62f6bf
  5. Oct 26, 2022
  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. Jun 01, 2022
  8. 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
  9. Feb 01, 2022
  10. Nov 25, 2021
    • Matthew Pickering's avatar
      Don't use implicit lifting when deriving Lift · 4d34bf15
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      It isn't much more complicated to be more precise when deriving Lift so
      we now generate
      
      ```
      data Foo = Foo Int Bool
      
      instance Lift Foo where
        lift (Foo a b) = [| Foo $(lift a) $(lift b) |]
        liftTyped (Foo a b) = [|| Foo $$(lift a) $$(lift b) |]
      ```
      
      This fixes #20688 which complained about using implicit lifting in the
      derived code.
      4d34bf15
  11. Nov 20, 2021
    • sheaf's avatar
      Include "not more specific" info in overlap msg · 742d8b60
      sheaf authored and Marge Bot's avatar Marge Bot committed
        When instances overlap, we now include additional information
        about why we weren't able to select an instance: perhaps
        one instance overlapped another but was not strictly more specific,
        so we aren't able to directly choose it.
      
      Fixes #20542
      742d8b60
  12. Mar 09, 2021
    • Simon Peyton Jones's avatar
      Fixes to dealing with the export of main · 8fe274e2
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      It's surprisingly tricky to deal with 'main' (#19397). This
      patch does quite bit of refactoring do to it right. Well,
      more-right anyway!
      
      The moving parts are documented in GHC.Tc.Module
         Note [Dealing with main]
      
      Some other oddments:
      
      * Rename tcRnExports to rnExports; no typechecking here!
      
      * rnExports now uses checkNoErrs rather than failIfErrsM;
        the former fails only if rnExports itself finds errors
      
      * Small improvements to tcTyThingCategory, which ultimately
        weren't important to the patch, but I've retained as
        a minor improvement.
      8fe274e2
  13. Aug 05, 2020
    • Ryan Scott's avatar
      Make CodeQ and TExpQ levity polymorphic · fbcb886d
      Ryan Scott authored and Marge Bot's avatar Marge Bot committed
      The patch is quite straightforward. The only tricky part is that
      `Language.Haskell.TH.Lib.Internal` now must be `Trustworthy` instead
      of `Safe` due to the `GHC.Exts` import (in order to import `TYPE`).
      
      Since `CodeQ` has yet to appear in any released version of
      `template-haskell`, I didn't bother mentioning the change to `CodeQ`
      in the `template-haskell` release notes.
      
      Fixes #18521.
      fbcb886d
  14. Jul 21, 2020
    • Matthew Pickering's avatar
      Use a newtype `Code` for the return type of typed quotations (Proposal #195) · a6257192
      Matthew Pickering authored and Ben Gamari's avatar Ben Gamari committed
      There are three problems with the current API:
      
      1. It is hard to properly write instances for ``Quote m => m (TExp a)`` as the type is the composition
         of two type constructors. Doing so in your program involves making your own newtype and
         doing a lot of wrapping/unwrapping.
      
         For example, if I want to create a language which I can either run immediately or
         generate code from I could write the following with the new API. ::
      
            class Lang r where
              _int :: Int -> r Int
              _if  :: r Bool -> r a -> r a -> r a
      
            instance Lang Identity where
              _int = Identity
              _if (Identity b) (Identity t) (Identity f) = Identity (if b then t else f)
      
            instance Quote m => Lang (Code m) where
              _int = liftTyped
              _if cb ct cf = [|| if $$cb then $$ct else $$cf ||]
      
      2. When doing code generation it is common to want to store code fragments in
         a map. When doing typed code generation, these code fragments contain a
         type index so it is desirable to store them in one of the parameterised
         map data types such as ``DMap`` from ``dependent-map`` or ``MapF`` from
         ``parameterized-utils``.
      
         ::
      
            compiler :: Env -> AST a -> Code Q a
      
            data AST a where ...
            data Ident a = ...
      
            type Env = MapF Ident (Code Q)
      
            newtype Code m a = Code (m (TExp a))
      
         In this example, the ``MapF`` maps an ``Ident String`` directly to a ``Code Q String``.
         Using one of these map types currently requires creating your own newtype and constantly
         wrapping every quotation and unwrapping it when using a splice. Achievable, but
         it creates even more syntactic noise than normal metaprogramming.
      
      3. ``m (TExp a)`` is ugly to read and write, understanding ``Code m a`` is
         easier. This is a weak reason but one everyone
         can surely agree with.
      
      Updates text submodule.
      a6257192
  15. Jun 10, 2020
    • Luke Lau's avatar
      Fix lookupGlobalOccRn_maybe sometimes reporting an error · 32fd37f5
      Luke Lau authored and Marge Bot's avatar Marge Bot committed
      In some cases it was possible for lookupGlobalOccRn_maybe to return an
      error, when it should be returning a Nothing. If it called
      lookupExactOcc_either when there were no matching GlobalRdrElts in the
      otherwise case, it would return an error message. This could be caused
      when lookupThName_maybe in Template Haskell was looking in different
      namespaces (thRdrNameGuesses), guessing different namespaces that the
      name wasn't guaranteed to be found in.
      
      However, by addressing this some more accurate errors were being lost in
      the conversion to Maybes. So some of the lookup* functions have been
      shuffled about so that errors should always be ignored in
      lookup*_maybes, and propagated otherwise.
      
      This fixes #18263
      32fd37f5
  16. Apr 28, 2020
  17. Feb 21, 2020
  18. Feb 11, 2020
  19. 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
  20. Jul 10, 2019
    • Ömer Sinan Ağacan's avatar
      Testsuite tweaks and refactoring · d7423f10
      Ömer Sinan Ağacan authored and Marge Bot's avatar Marge Bot committed
      - Rename requires_th to req_th for consistency with other req functions
        (e.g. req_interp, req_profiling etc.)
      
      - req_th (previously requires_th) now checks for interpreter (via
        req_interp). With this running TH tests are skipped when running the
        test suite with stage=1.
      
      - Test tweaks:
          - T9360a, T9360b: Use req_interp
          - recomp009, T13938, RAE_T32a: Use req_th
      
      - Fix check-makefiles linter: it now looks for Makefiles instead of .T
        files (which are actually Python files)
      d7423f10
  21. Jun 12, 2019
  22. Apr 19, 2019
    • Alec Theriault's avatar
      Add test case for #16384 · fdfd9731
      Alec Theriault authored and Marge Bot's avatar Marge Bot committed
      Now that `TExp` accepts unlifted types, #16384 is fixed. Since the real
      issue there was GHC letting through an ill-kinded type which
      `-dcore-lint` rightly rejected, a reasonable regression test is that
      the program from #16384 can now be accepted without `-dcore-lint`
      complaining.
      fdfd9731
    • Alec Theriault's avatar
      TH: make `Lift` and `TExp` levity-polymorphic · 57cf1133
      Alec Theriault authored and Marge Bot's avatar Marge Bot committed
      Besides the obvious benefits of being able to manipulate `TExp`'s of
      unboxed types, this also simplified `-XDeriveLift` all while making
      it more capable.
      
        * `ghc-prim` is explicitly depended upon by `template-haskell`
      
        * The following TH things are parametrized over `RuntimeRep`:
      
            - `TExp(..)`
            - `unTypeQ`
            - `unsafeTExpCoerce`
            - `Lift(..)`
      
        * The following instances have been added to `Lift`:
      
            - `Int#`, `Word#`, `Float#`, `Double#`, `Char#`, `Addr#`
            - unboxed tuples of lifted types up to arity 7
            - unboxed sums of lifted types up to arity 7
      
          Ideally we would have levity-polymorphic _instances_ of unboxed
          tuples and sums.
      
        * The code generated by `-XDeriveLift` uses expression quotes
          instead of generating large amounts of TH code and having
          special hard-coded cases for some unboxed types.
      57cf1133
  23. Mar 15, 2019
  24. Nov 30, 2018
    • Alec Theriault's avatar
      Add 'Lift' instances for 'NonEmpty' and 'Void' · 47875bd4
      Alec Theriault authored and Ryan Scott's avatar Ryan Scott committed
      Summary:
      Since 'NonEmpty' and 'Void' are now part of 'base', it makes
      sense that we put 'Lift' instances for them in 'template-haskell'.
      Not doing so is going to force users to define their own (possibly
      colliding) orphan instances downstream.
      
      Test Plan: ./validate
      
      Reviewers: goldfire, bgamari, RyanGlScott
      
      Reviewed By: RyanGlScott
      
      Subscribers: RyanGlScott, rwbarton, carter
      
      GHC Trac Issues: #15961
      
      Differential Revision: https://phabricator.haskell.org/D5391
      47875bd4
  25. Jul 28, 2017
    • Ryan Scott's avatar
      Merge types and kinds in DsMeta · b3b564fb
      Ryan Scott authored
      Summary:
      Types and kinds are now the same in GHC... well, except in the code
      that involves Template Haskell, where types and kinds are given separate
      treatment. This aims to unify that treatment in the `DsMeta` module.
      
      The gist of this patch is replacing all uses of `repLKind` with `repLTy`.
      This is isn't quite as simple as one might imagine, since `repLTy` returns a
      `Core (Q Type)` (a monadic expression), whereas `repLKind` returns a
      `Core Kind` (a pure expression). This causes many awkward impedance mismatches.
      
      One option would be to change every combinator in `Language.Haskell.TH.Lib` to
      take `KindQ` as an argument instead of `Kind`. But this would be a breaking
      change of colossal proportions.
      
      Instead, this patch takes a somewhat different approach. This migrates the
      existing `Language.Haskell.TH.Lib` module to
      `Language.Haskell.TH.Lib.Internal`, and changes all `Kind`-related combinators
      in `Language.Haskell.TH.Lib.Internal` to live in `Q`. The new
      `Language.Haskell.TH.Lib` module then re-exports most of
      `Language.Haskell.TH.Lib.Internal` with the exception of the `Kind`-related
      combinators, for which it redefines them to be their current definitions (which
      don't live in `Q`). This allows us to retain backwards compatibility with
      previous `template-haskell` releases, but more importantly, it allows GHC to
      make as many changes to the `Internal` code as it wants for its purposes
      without fear of disrupting the public API.
      
      This solves half of #11785 (the other half being `TcSplice`).
      
      Test Plan: ./validate
      
      Reviewers: goldfire, austin, bgamari
      
      Reviewed By: goldfire
      
      Subscribers: rwbarton, thomie
      
      GHC Trac Issues: #11785
      
      Differential Revision: https://phabricator.haskell.org/D3751
      b3b564fb
  26. Feb 26, 2017
    • rwbarton's avatar
      tests: remove extra_files.py (#12223) · 3415bcaa
      rwbarton authored and Ben Gamari's avatar Ben Gamari committed
      The script I used is included as testsuite/driver/kill_extra_files.py,
      though at this point it is for mostly historical interest.
      
      Some of the tests in libraries/hpc relied on extra_files.py, so this
      commit includes an update to that submodule.
      
      One test in libraries/process also relies on extra_files.py, but we
      cannot update that submodule so easily, so for now we special-case it
      in the test driver.
      3415bcaa
  27. Jan 22, 2017
  28. Jun 18, 2016
  29. May 12, 2016
  30. Feb 25, 2016
  31. Feb 23, 2016
  32. Feb 09, 2016
    • Ben Gamari's avatar
      TcErrors: Fix plural form of "instance" error · c8702e30
      Ben Gamari authored
      Previously "types" was inappropriately made plural instead of
      "instance",
      
          instance Eq Ordering -- Defined in ‘GHC.Classes’
          ...plus 24 others
          ...plus 13 instance involving out-of-scope typess
      c8702e30
  33. Dec 15, 2015
    • Ben Gamari's avatar
      Narrow scope of special-case for unqualified printing of names in core libraries · e2c91738
      Ben Gamari authored and Ben Gamari's avatar Ben Gamari committed
      Commit 547c5971 modifies the
      pretty-printer to render names from a set of core packages (`base`,
      `ghc-prim`, `template-haskell`) as unqualified. The idea here was that
      many of these names typically are not in scope but are well-known by the
      user and therefore qualification merely introduces noise.
      
      This, however, is a very large hammer and potentially breaks any
      consumer who relies on parsing GHC output (hence #11208). This commit
      partially reverts this change, now only printing `Constraint` (which
      appears quite often in errors) as unqualified.
      
      Fixes #11208.
      
      Updates tests in `array` submodule.
      
      Test Plan: validate
      
      Reviewers: hvr, thomie, austin
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1619
      
      GHC Trac Issues: #11208
      e2c91738
  34. Nov 29, 2015
    • Herbert Valerio Riedel's avatar
      Implement new -XTemplateHaskellQuotes pragma · 85fcd035
      Herbert Valerio Riedel authored and Ben Gamari's avatar Ben Gamari committed
      Since f16ddcee / D876, `ghc-stage1`
      supports a subset of `-XTemplateHaskell`, but since we need Cabal to be
      able detect (so `.cabal` files can be specified accordingly, see also
      GHC #11102 which omits `TemplateHaskell` from `--supported-extensions`)
      whether GHC provides full or only partial `-XTemplateHaskell` support,
      the proper way to accomplish this is to split off the
      quotation/non-splicing `TemplateHaskell` feature-subset into a new
      language pragma `TemplateHaskellQuotes`.
      
      Moreover, `-XTemplateHaskellQuotes` is considered safe under SafeHaskell
      
      This addresses #11121
      
      Reviewers: goldfire, ezyang, dterei, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1511
      
      GHC Trac Issues: #11121
      85fcd035
  35. Oct 08, 2015
  36. Sep 03, 2015
  37. Sep 02, 2015
  38. May 11, 2015
    • Edward Z. Yang's avatar
      Support stage 1 Template Haskell (non-quasi) quotes, fixes #10382. · f16ddcee
      Edward Z. Yang authored
      
      Summary:
      This commit adds stage 1 support for Template Haskell
      quoting, e.g. [| ... expr ... |], which is useful
      for authors of quasiquoter libraries that do not actually
      need splices.  The TemplateHaskell extension now does not
      unconditionally fail; it only fails if the renamer encounters
      a splice that it can't run.
      
      In order to make sure the referenced data structures
      are consistent, template-haskell is now a boot library.
      There are some minor BC changes to template-haskell to make it boot
      on GHC 7.8.
      
      Note for reviewer: big diff changes are simply code
      being moved out of an ifdef; there was no other substantive
      change to that code.
      
      Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
      
      Test Plan: validate
      
      Reviewers: simonpj, austin, goldfire
      
      Subscribers: bgamari, thomie
      
      Differential Revision: https://phabricator.haskell.org/D876
      
      GHC Trac Issues: #10382
      f16ddcee
Loading