Skip to content
Snippets Groups Projects
  1. Oct 23, 2023
  2. 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
  3. Sep 18, 2023
  4. Sep 08, 2023
  5. Sep 07, 2023
  6. 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
  7. 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
  8. Jul 19, 2023
  9. 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
  10. May 04, 2023
  11. 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
  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. Jan 23, 2023
  14. 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
  15. Jan 17, 2023
  16. Jan 09, 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. 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
  21. 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
  22. 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
  23. Sep 27, 2022
  24. 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
  25. 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
  26. Aug 11, 2022
  27. 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
  28. Jul 03, 2022
  29. Jun 27, 2022
  30. Jun 06, 2022
  31. May 26, 2022
  32. May 13, 2022
    • Jack Hughes's avatar
      Fix printing of brackets in multiplicities (#20315) · 668a9ef4
      Jack Hughes authored and Marge Bot's avatar Marge Bot committed
      Change mulArrow to allow for printing of correct application precedence
      where necessary and update callers of mulArrow to reflect this.
      
      As part of this, move mulArrow from GHC/Utils/Outputtable to GHC/Iface/Type.
      
      Fixes #20315
      668a9ef4
  33. May 11, 2022
  34. Apr 08, 2022
  35. Apr 01, 2022
  36. Mar 28, 2022
  37. Dec 22, 2021
    • Alan Zimmerman's avatar
      Fix panic trying to -ddump-parsed-ast for implicit fixity · 09b6cb45
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      A declaration such as
      
          infixr ++++
      
      is supplied with an implicit fixity of 9 in the parser, but uses
      an invalid SrcSpan to capture this. Use of this span triggers a panic.
      
      Fix the problem by not recording an exact print annotation for the
      non-existent fixity source.
      
      Closes #20846
      09b6cb45
Loading