Skip to content
Snippets Groups Projects
  1. Mar 01, 2024
    • Torsten Schmits's avatar
      Introduce ListTuplePuns extension · d91d00fc
      Torsten Schmits authored and Marge Bot's avatar Marge Bot committed
      This implements Proposal 0475, introducing the `ListTuplePuns` extension
      which is enabled by default.
      
      Disabling this extension makes it invalid to refer to list, tuple and
      sum type constructors by using built-in syntax like `[Int]`,
      `(Int, Int)`, `(# Int#, Int# #)` or `(# Int | Int #)`.
      Instead, this syntax exclusively denotes data constructors for use with
      `DataKinds`.
      The conventional way of referring to these data constructors by
      prefixing them with a single quote (`'(Int, Int)`) is now a parser
      error.
      
      Tuple declarations have been moved to `GHC.Tuple.Prim` and the `Solo`
      data constructor has been renamed to `MkSolo` (in a previous commit).
      Unboxed tuples and sums now have real source declarations in `GHC.Types`.
      Unit and solo types for tuples are now called `Unit`, `Unit#`, `Solo`
      and `Solo#`.
      Constraint tuples now have the unambiguous type constructors `CTuple<n>`
      as well as `CUnit` and `CSolo`, defined in `GHC.Classes` like before.
      
      A new parser construct has been added for the unboxed sum data
      constructor declarations.
      
      The type families `Tuple`, `Sum#` etc. that were intended to provide
      nicer syntax have been omitted from this change set due to inference
      problems, to be implemented at a later time.
      See the MR discussion for more info.
      
      Updates the submodule utils/haddock.
      Updates the cabal submodule due to new language extension.
      
          Metric Increase:
              haddock.base
      
          Metric Decrease:
              MultiLayerModulesTH_OneShot
              size_hello_artifact
      
      Proposal document: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0475-tuple-syntax.rst
      
      Merge request: !8820
      
      Tracking ticket: #21294
      d91d00fc
  2. Feb 14, 2024
    • Alan Zimmerman's avatar
      EPA: Move EpAnn out of extension points · 0e01e1db
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      Leaving a few that are too tricky, maybe some other time.
      
      Also
       - remove some unneeded helpers from Parser.y
       - reduce allocations with strictness annotations
      
      Updates haddock submodule
      
      Metric Decrease:
          parsing001
      0e01e1db
  3. 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
  4. Jan 20, 2024
  5. Dec 13, 2023
  6. Dec 11, 2023
    • Vladislav Zavialov's avatar
      Make forall a keyword (#23719) · d9e4c597
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      Before this change, GHC used to accept `forall` as a term-level
      identifier:
      
      	-- from constraints-0.13
      	forall :: forall p. (forall a. Dict (p a)) -> Dict (Forall p)
      	forall d = ...
      
      Now it is a parse error.
      
      The -Wforall-identifier warning has served its purpose and is now
      a deprecated no-op.
      d9e4c597
  7. Nov 30, 2023
    • Alan Zimmerman's avatar
      EPA: EpaDelta for comment has no comments · c7623b22
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      EpaLocation is used to position things. It has two constructors,
      EpaSpan holding a SrcSpan, and EpaDelta with a delta position and a
      possible list of comments.  The comment list is needed because the
      location in EpaDelta has no absolute information to decide which
      comments should be emitted before them when printing.
      
      But it is also used for specifying the position of a comment.  To
      prevent the absurdity of a comment position having a list of comments
      in it, we make EpaLocation parameterisable, using comments for the
      normal case and a constant for within comments.
      
      Updates haddock submodule.
      
      aarch64-darwin
      Metric Decrease:
          MultiLayerModulesTH_OneShot
      c7623b22
  8. Nov 27, 2023
    • Alan Zimmerman's avatar
      EPA: Remove SrcSpanAnn · 4e5ff6a4
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      Now that we only have a single constructor for EpAnn, And it uses a
      SrcSpan for its location, we can do away with SrcSpanAnn completely.
      It only existed to wrap the original SrcSpan in a location, and
      provide a place for the exact print annotation.
      
      For darwin only:
      Metric Increase:
          MultiLayerModulesTH_OneShot
      
      Updates haddock submodule
      4e5ff6a4
  9. Nov 26, 2023
    • Alan Zimmerman's avatar
      EPA: Remove EpAnnNotUsed · 7902ebf8
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      We no longer need the EpAnnNotUsed constructor for EpAnn, as we can
      represent an unused annotation with an anchor having a EpaDelta of
      zero, and empty comments and annotations.
      
      This simplifies code handling annotations considerably.
      
      Updates haddock submodule
      
      Metric Increase:
          parsing001
      7902ebf8
  10. Nov 20, 2023
    • Alan Zimmerman's avatar
      EPA: Use SrcSpan in EpaSpan · 48bf364e
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      This is more natural, since we already need to deal with invalid
      RealSrcSpans, and that is exactly what SrcSpan.UnhelpfulSpan is for.
      
      Updates haddock submodule.
      48bf364e
  11. Nov 12, 2023
    • Alan Zimmerman's avatar
      EPA: Replace Anchor with EpaLocation · 3f0036ec
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      An Anchor has a location and an operation, which is either that it is
      unchanged or that it has moved with a DeltaPos
      
          data Anchor = Anchor { anchor :: RealSrcSpan
                               , anchor_op :: AnchorOperation }
      
      An EpaLocation also has either a location or a DeltaPos
      
          data EpaLocation = EpaSpan !RealSrcSpan !(Strict.Maybe BufSpan)
                           | EpaDelta !DeltaPos ![LEpaComment]
      
      Now that we do not care about always having a location in the anchor,
      we remove Anchor and replace it with EpaLocation
      
      We do this with a type alias initially, to ease the transition.
      The alias will be removed in time.
      
      We also have helpers to reconstruct the AnchorOperation from an
      EpaLocation. This is also temporary.
      
      Updates Haddock submodule
      3f0036ec
  12. Oct 23, 2023
  13. Sep 30, 2023
    • Simon Peyton Jones's avatar
      Refactor to combine HsLam and HsLamCase · ef5342cd
      Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
      This MR is pure refactoring (#23916):
      * Combine `HsLam` and `HsLamCase`
      * Combine `HsCmdLam` and `HsCmdLamCase`
      
      This just arranges to treat uniformly
         \x -> e
         \case pi -> ei
         \cases pis -> ie
      
      In the exising code base the first is treated differently
      to the latter two.
      
      No change in behaviour.
      
      More specifics:
      
      * Combine `HsLam` and `HsLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsExpr`) into one data construtor covering
        * Lambda
        * `\case`
        * `\cases`
      
      * The new `HsLam` has an argument of type `HsLamVariant` to distinguish the three cases.
      
      * Similarly, combine `HsCmdLam` and `HsCmdLamCase` (constructors of `Language.Haskell.Syntax.Expr.HsCmd` ) into one.
      
      * Similarly, combine `mkHsLamPV` and `mkHsLamCasePV` (methods of class `DisambECP`) into one. (Thank you Alan Zimmerman.)
      
      * Similarly, combine `LambdaExpr` and `LamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsMatchContext`) into one: `LamAlt` with a `HsLamVariant` argument.
      
      * Similarly, combine `KappaExpr` and `ArrowLamCaseAlt` (constructors of `Language.Haskell.Syntax.Expr.HsArrowMatchContext`) into one: `ArrowLamAlt` with a `HsLamVariant` argument.
      
      * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one.
      
      * Similarly, combine `PsErrLambdaInPat` and `PsErrLambdaCaseInPat` (constructors of `GHC.Parser.Errors.Ppr.PsError`) into one.
      
      * In the same `PsError` data type, combine `PsErrLambdaCmdInFunAppCmd` and `PsErrLambdaCaseCmdInFunAppCmd` into one.
      
      * In the same `PsError` data tpye, combine `PsErrLambdaInFunAppExpr` and `PsErrLambdaCaseInFunAppExpr` into one.
      
      p* Smilarly combine `ExpectedFunTyLam` and `ExpectedFunTyLamCase` (constructors of `GHC.Tc.Types.Origin.ExpectedFunTyOrigin`) into one.
      
      Phew!
      ef5342cd
  14. Sep 18, 2023
  15. Sep 08, 2023
  16. Sep 07, 2023
  17. Aug 01, 2023
    • Bartłomiej Cieślar's avatar
      Implementation of the Deprecated Instances proposal #575 · d2bedffd
      Bartłomiej Cieślar authored and Marge Bot's avatar Marge Bot committed
      
      This commit implements the ability to deprecate certain instances,
      which causes the compiler to emit the desired deprecation message
      whenever they are instantiated. For example:
      
        module A where
        class C t where
        instance {-# DEPRECATED "dont use" #-} C Int where
      
        module B where
        import A
        f :: C t => t
        f = undefined
        g :: Int
        g = f -- "dont use" emitted here
      
      The implementation is as follows:
        - In the parser, we parse deprecations/warnings attached to instances:
      
            instance {-# DEPRECATED "msg" #-} Show X
            deriving instance {-# WARNING "msg2" #-} Eq Y
      
          (Note that non-standalone deriving instance declarations do not support
          this mechanism.)
      
        - We store the resulting warning message in `ClsInstDecl` (respectively, `DerivDecl`).
          In `GHC.Tc.TyCl.Instance.tcClsInstDecl` (respectively, `GHC.Tc.Deriv.Utils.newDerivClsInst`),
          we pass on that information to `ClsInst` (and eventually store it in `IfaceClsInst` too).
      
        - Finally, when we solve a constraint using such an instance, in
          `GHC.Tc.Instance.Class.matchInstEnv`, we emit the appropriate warning
          that was stored in `ClsInst`.
          Note that we only emit a warning when the instance is used in a different module
          than it is defined, which keeps the behaviour in line with the deprecation of
          top-level identifiers.
      
      Signed-off-by: default avatarBartłomiej Cieślar <bcieslar2001@gmail.com>
      d2bedffd
  18. Jul 25, 2023
    • Matthew Pickering's avatar
      Fix pretty printing of WARNING pragmas · 822ef66b
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      There is still something quite unsavoury going on with WARNING pragma
      printing because the printing relies on the fact that for decl
      deprecations the SourceText of WarningTxt is empty. However, I let that
      lion sleep and just fixed things directly.
      
      Fixes #23465
      822ef66b
  19. Jul 19, 2023
  20. Jun 21, 2023
    • Bartłomiej Cieślar's avatar
      Add support for deprecating exported items (proposal #134) · 711b1d24
      Bartłomiej Cieślar authored and Ben Gamari's avatar Ben Gamari committed
      
      This is an implementation of the deprecated exports proposal #134.
      The proposal introduces an ability to introduce warnings to exports.
      This allows for deprecating a name only when it is exported from a specific
      module, rather than always depreacting its usage. In this example:
      
          module A ({-# DEPRECATED "do not use" #-} x) where
          x = undefined
          ---
          module B where
          import A(x)
      
      `x` will emit a warning when it is explicitly imported.
      
      Like the declaration warnings, export warnings are first accumulated within
      the `Warnings` struct, then passed into the ModIface, from which they are
      then looked up and warned about in the importing module in the `lookup_ie`
      helpers of the `filterImports` function (for the explicitly imported names)
      and in the `addUsedGRE(s)` functions where they warn about regular usages
      of the imported name.
      
      In terms of the AST information, the custom warning is stored in the
      extension field of the variants of the `IE` type (see Trees that Grow for
      more information).
      
      The commit includes a bump to the haddock submodule added in MR #28
      
      Signed-off-by: default avatarBartłomiej Cieślar <bcieslar2001@gmail.com>
      711b1d24
    • Sylvain Henry's avatar
      JS: implement TH support · 4d356ea3
      Sylvain Henry authored
      
      - Add ghc-interp.js bootstrap script for the JS interpreter
      - Interactively link and execute iserv code from the ghci package
      - Incrementally load and run JS code for splices into the running iserv
      
      Co-authored-by: default avatarLuite Stegeman <stegeman@gmail.com>
      4d356ea3
  21. May 04, 2023
  22. Apr 26, 2023
    • Alan Zimmerman's avatar
      EPA: Use ExplicitBraces only in HsModule · 052e2bb6
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      !9018 brought in exact print annotations in LayoutInfo for open and
      close braces at the top level.
      
      But it retained them in the HsModule annotations too.
      
      Remove the originals, so exact printing uses LayoutInfo
      052e2bb6
  23. 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
  24. Jan 23, 2023
  25. Jan 19, 2023
    • Andrei Borzenkov's avatar
      Fix printing of promoted MkSolo datacon (#22785) · 14b5982a
      Andrei Borzenkov authored and Marge Bot's avatar Marge Bot committed
      Problem: In 2463df2f, the Solo data constructor was renamed to MkSolo,
      and Solo was turned into a pattern synonym for backwards compatibility.
      Since pattern synonyms can not be promoted, the old code that pretty-printed
      promoted single-element tuples started producing ill-typed code:
         t :: Proxy ('Solo Int)
      This fails with "Pattern synonym ‘Solo’ used as a type"
      
      The solution is to track the distinction between type constructors and data
      constructors more carefully when printing single-element tuples.
      14b5982a
  26. Jan 17, 2023
  27. Jan 09, 2023
  28. 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
  29. Dec 23, 2022
  30. Dec 14, 2022
  31. 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
  32. Nov 24, 2022
    • Vladislav Zavialov's avatar
      Check if the SDoc starts with a single quote (#22488) · 178c1fd8
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      This patch fixes pretty-printing of character literals
      inside promoted lists and tuples.
      
      When we pretty-print a promoted list or tuple whose first element
      starts with a single quote, we want to add a space between the opening
      bracket and the element:
      
      	'[True]    -- ok
      	'[ 'True]  -- ok
      	'['True]   -- not ok
      
      If we don't add the space, we accidentally produce a character
      literal '['.
      
      Before this patch, pprSpaceIfPromotedTyCon inspected the type as an AST
      and tried to guess if it would be rendered with a single quote. However,
      it missed the case when the inner type was itself a character literal:
      
      	'[ 'x']  -- ok
      	'['x']   -- not ok
      
      Instead of adding this particular case, I opted for a more future-proof
      solution: check the SDoc directly. This way we can detect if the single
      quote is actually there instead of trying to predict it from the AST.
      The new function is called spaceIfSingleQuote.
      178c1fd8
  33. 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
  34. Sep 27, 2022
  35. 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
  36. 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
  37. Aug 11, 2022
  38. Jul 06, 2022
    • Rodrigo Mesquita's avatar
      Remove many GHC dependencies from L.H.S · fd379d1b
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      Continue to prune the `Language.Haskell.Syntax.*` modules out of GHC
      imports according to the plan in the linked issue.
      
      Moves more GHC-specific declarations to `GHC.*` and brings more required
      GHC-independent declarations to `Language.Haskell.Syntax.*` (extending
      e.g. `Language.Haskell.Syntax.Basic`).
      
      Progress towards #21592
      
      Bump haddock submodule for !8308
      
      -------------------------
      Metric Decrease:
          hard_hole_fits
      -------------------------
      fd379d1b
  39. Jul 03, 2022
Loading