Skip to content
Snippets Groups Projects
  1. Jul 06, 2023
  2. Jun 15, 2023
  3. Jun 13, 2023
  4. May 27, 2023
    • Alan Zimmerman's avatar
      EPA: Better fix for #22919 · 69fdbece
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      The original fix for #22919 simply removed the ability to match up
      prior comments with the first declaration in the file.
      
      Restore it, but add a check that the comment is on a single line, by
      ensuring that it comes immediately prior to the next thing (comment or
      start of declaration), and that the token preceding it is not on the
      same line.
      
      closes #22919
      69fdbece
  5. May 26, 2023
    • Matthew Pickering's avatar
      error messages: Don't display ghci specific hints for missing packages · 34b44f7d
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      Tickets like #22884 suggest that it is confusing that GHC used on the
      command line can suggest options which only work in GHCi.
      
      This ticket uses the error message infrastructure to override certain
      error messages which displayed GHCi specific information so that this
      information is only showed when using GHCi.
      
      The main annoyance is that we mostly want to display errors in the same
      way as before, but with some additional information. This means that the
      error rendering code has to be exported from the Iface/Errors/Ppr.hs
      module.
      
      I am unsure about whether the approach taken here is the best or most
      maintainable solution.
      
      Fixes #22884
      34b44f7d
  6. May 19, 2023
  7. May 18, 2023
  8. May 16, 2023
    • Zubin's avatar
      compiler: Use compact representation for SourceText · 90e69d5d
      Zubin authored and Marge Bot's avatar Marge Bot committed
      SourceText is serialized along with INLINE pragmas into interface files. Many of
      these SourceTexts are identical, for example "{-# INLINE#". When deserialized,
      each such SourceText was previously expanded out into a [Char], which is highly
      wasteful of memory, and each such instance of the text would allocate an
      independent list with its contents as deserializing breaks any sharing that might
      have existed.
      
      Instead, we use a `FastString` to represent these, so that each instance unique
      text will be interned and stored in a memory efficient manner.
      90e69d5d
  9. Apr 27, 2023
    • Cheng Shao's avatar
      testsuite: add the req_process predicate · ce580426
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      This patch adds the req_process predicate to the testsuite to assert
      the platform has a process model, also marking tests that involve
      spawning processes as req_process. Also bumps hpc & process submodule.
      ce580426
  10. Apr 26, 2023
  11. Apr 25, 2023
  12. Apr 18, 2023
    • Matthew Pickering's avatar
      Convert interface file loading errors into proper diagnostics · 5e1d33d7
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      This patch converts all the errors to do with loading interface files
      into proper structured diagnostics.
      
      * DriverMessage: Sometimes in the driver we attempt to load an interface
        file so we embed the IfaceMessage into the DriverMessage.
      * TcRnMessage: Most the time we are loading interface files during
        typechecking, so we embed the IfaceMessage
      
      This patch also removes the TcRnInterfaceLookupError constructor which
      is superceded by the IfaceMessage, which is now structured compared to
      just storing an SDoc before.
      5e1d33d7
  13. Mar 30, 2023
  14. Mar 21, 2023
    • Andrei Borzenkov's avatar
      Rename () into Unit, (,,...,,) into Tuple<n> (#21294) · a13affce
      Andrei Borzenkov authored and Marge Bot's avatar Marge Bot committed
      
      This patch implements a part of GHC Proposal #475.
      The key change is in GHC.Tuple.Prim:
      
        - data () = ()
        - data (a,b) = (a,b)
        - data (a,b,c) = (a,b,c)
        ...
        + data Unit = ()
        + data Tuple2 a b = (a,b)
        + data Tuple3 a b c = (a,b,c)
        ...
      
      And the rest of the patch makes sure that Unit and Tuple<n>
      are pretty-printed as () and (,,...,,) in various contexts.
      
      Updates the haddock submodule.
      
      Co-authored-by: default avatarVladislav Zavialov <vlad.z.4096@gmail.com>
      a13affce
  15. Feb 08, 2023
  16. Feb 06, 2023
  17. Jan 05, 2023
    • Alan Zimmerman's avatar
      EPA: Do not collect comments from end of file · 22bb8998
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      In Parser.y semis1 production triggers for the virtual semi at the end
      of the file. This is detected by it being zero length.
      
      In this case, do not extend the span being used to gather comments, so
      any final comments are allocated at the module level instead.
      22bb8998
  18. Dec 23, 2022
  19. Dec 14, 2022
  20. Dec 09, 2022
    • Krzysztof Gogolewski's avatar
      Fixes around primitive literals · b0cc2fcf
      Krzysztof Gogolewski authored and Marge Bot's avatar Marge Bot committed
      * The SourceText of primitive characters 'a'# did not include
        the #, unlike for other primitive literals 1#, 1##, 1.0#, 1.0##, "a"#.
        We can now remove the function pp_st_suffix, which was a hack
        to add the # back.
      * Negative primitive literals shouldn't use parentheses, as described in
        Note [Printing of literals in Core]. Added a testcase to T14681.
      b0cc2fcf
  21. Nov 29, 2022
  22. Oct 18, 2022
    • Matthew Pickering's avatar
      Allow configuration of error message printing · e1bbd368
      Matthew Pickering authored and sheaf's avatar sheaf committed
      This MR implements the idea of #21731 that the printing of a diagnostic
      method should be configurable at the printing time.
      
      The interface of the `Diagnostic` class is modified from:
      
      ```
      class Diagnostic a where
        diagnosticMessage :: a -> DecoratedSDoc
        diagnosticReason  :: a -> DiagnosticReason
        diagnosticHints   :: a -> [GhcHint]
      ```
      
      to
      
      ```
      class Diagnostic a where
        type DiagnosticOpts a
        defaultDiagnosticOpts :: DiagnosticOpts a
        diagnosticMessage :: DiagnosticOpts a -> a -> DecoratedSDoc
        diagnosticReason  :: a -> DiagnosticReason
        diagnosticHints   :: a -> [GhcHint]
      ```
      
      and so each `Diagnostic` can implement their own configuration record
      which can then be supplied by a client in order to dictate how to print
      out the error message.
      
      At the moment this only allows us to implement #21722 nicely but in
      future it is more natural to separate the configuration of how much
      information we put into an error message and how much we decide to print
      out of it.
      
      Updates Haddock submodule
      e1bbd368
  23. Oct 17, 2022
    • Alan Zimmerman's avatar
      Update the check-exact infrastructure to match ghc-exactprint · d80ad2f4
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      GHC tests the exact print annotations using the contents of
      utils/check-exact.
      
      The same functionality is provided via
      https://github.com/alanz/ghc-exactprint
      
      The latter was updated to ensure it works with all of the files on
      hackage when 9.2 was released, as well as updated to ensure users of
      the library could work properly (apply-refact, retrie, etc).
      
      This commit brings the changes from ghc-exactprint into
      GHC/utils/check-exact, adapting for the changes to master.
      
      Once it lands, it will form the basis for the 9.4 version of
      ghc-exactprint.
      
      See also discussion around this process at #21355
      d80ad2f4
  24. Sep 27, 2022
  25. Sep 19, 2022
    • Matthew Farkas-Dyck's avatar
      Scrub partiality about `NewOrData`. · c1f81b38
      Matthew Farkas-Dyck authored and Marge Bot's avatar Marge Bot committed
      Rather than a list of constructors and a `NewOrData` flag, we define `data DataDefnCons a = NewTypeCon a | DataTypeCons [a]`, which enforces a newtype to have exactly one constructor.
      
      Closes #22070.
      
      Bump haddock submodule.
      c1f81b38
  26. Sep 15, 2022
  27. 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
  28. Jul 03, 2022
  29. May 26, 2022
  30. May 24, 2022
    • Alan Zimmerman's avatar
      EPA : Remove duplicate comments in DataFamInstD · e9fff12b
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      The code
      
        data instance Method PGMigration = MigrationQuery Query
                                         -- ^ Run a query against the database
                                         | MigrationCode (Connection -> IO (Either String ()))
                                         -- ^ Run any arbitrary IO code
      
      Resulted in two instances of the "-- ^ Run a query against the database"
      comment appearing in the Exact Print Annotations when it was parsed.
      
      Ensure only one is kept.
      
      Closes #20239
      e9fff12b
  31. May 21, 2022
    • Norman Ramsey's avatar
      Change `Backend` type and remove direct dependencies · 4aa3c5bd
      Norman Ramsey authored and Cheng Shao's avatar Cheng Shao committed
      With this change, `Backend` becomes an abstract type
      (there are no more exposed value constructors).
      Decisions that were formerly made by asking "is the
      current back end equal to (or different from) this named value
      constructor?" are now made by interrogating the back end about
      its properties, which are functions exported by `GHC.Driver.Backend`.
      
      There is a description of how to migrate code using `Backend` in the
      user guide.
      
      Clients using the GHC API can find a backdoor to access the Backend
      datatype in GHC.Driver.Backend.Internal.
      
      Bumps haddock submodule.
      
      Fixes #20927
      4aa3c5bd
  32. Apr 06, 2022
    • Zubin's avatar
      Add warnings for file header pragmas that appear in the body of a module (#20385) · babb47d2
      Zubin authored and Marge Bot's avatar Marge Bot committed
      Once we are done parsing the header of a module to obtain the options, we
      look through the rest of the tokens in order to determine if they contain any
      misplaced file header pragmas that would usually be ignored, potentially
      resulting in bad error messages.
      
      The warnings are reported immediately so that later errors don't shadow
      over potentially helpful warnings.
      
      Metric Increase:
        T13719
      babb47d2
  33. Mar 23, 2022
    • Zubin's avatar
      hi haddock: Lex and store haddock docs in interface files · b91798be
      Zubin authored and Marge Bot's avatar Marge Bot committed
      Names appearing in Haddock docstrings are lexed and renamed like any other names
      appearing in the AST. We currently rename names irrespective of the namespace,
      so both type and constructor names corresponding to an identifier will appear in
      the docstring. Haddock will select a given name as the link destination based on
      its own heuristics.
      
      This patch also restricts the limitation of `-haddock` being incompatible with
      `Opt_KeepRawTokenStream`.
      
      The export and documenation structure is now computed in GHC and serialised in
      .hi files. This can be used by haddock to directly generate doc pages without
      reparsing or renaming the source. At the moment the operation of haddock
      is not modified, that's left to a future patch.
      
      Updates the haddock submodule with the minimum changes needed.
      b91798be
  34. Mar 14, 2022
    • Rodrigo Mesquita's avatar
      TTG Pull AbsBinds and ABExport out of the main AST · 135888dd
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      AbsBinds and ABExport both depended on the typechecker, and were thus
      removed from the main AST Expr.
      
      CollectPass now has a new function `collectXXHsBindsLR` used for the new
      HsBinds extension point
      
      Bumped haddock submodule to work with AST changes.
      
      The removed Notes from Language.Haskell.Syntax.Binds were duplicated
      (and not referenced) and the copies in GHC.Hs.Binds are kept (and
      referenced there). (See #19252)
      135888dd
  35. 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
  36. Dec 10, 2021
  37. Dec 07, 2021
  38. Oct 08, 2021
    • abarbu's avatar
      Add defaulting plugins. · a76409c7
      abarbu authored
      Like the built-in type defaulting rules these plugins can propose candidates
      to resolve ambiguous type variables.
      
      Machine learning and other large APIs like those for game engines introduce
      new numeric types and other complex typed APIs. The built-in defaulting
      mechanism isn't powerful enough to resolve ambiguous types in these cases forcing
      users to specify minutia that they might not even know how to do. There is
      an example defaulting plugin linked in the documentation. Applications include
      defaulting the device a computation executes on, if a gradient should be
      computed for a tensor, or the size of a tensor.
      
      See https://github.com/ghc-proposals/ghc-proposals/pull/396 for details.
      a76409c7
  39. Sep 11, 2021
Loading