Skip to content
Snippets Groups Projects
  1. 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
  2. Feb 08, 2024
    • Vladislav Zavialov's avatar
      Haddock comments on infix constructors (#24221) · e8fb2451
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      Rewrite the `HasHaddock` instance for `ConDecl GhcPs` to account for
      infix constructors.
      
      This change fixes a Haddock regression (introduced in 19e80b9a)
      that affected leading comments on infix data constructor declarations:
      
      	-- | Docs for infix constructor
      	| Int :* Bool
      
      The comment should be associated with the data constructor (:*), not
      with its left-hand side Int.
      e8fb2451
  3. Dec 13, 2023
  4. 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
  5. 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
  6. 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
  7. Nov 02, 2023
    • Alan Zimmerman's avatar
      EPA: Use full range for Anchor · 81fb8885
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      This change requires a series of related changes, which must all land
      at the same time, otherwise all the EPA tests break.
      
      * Use the current Anchor end as prior end
      
        Use the original anchor location end as the source of truth for
        calculating print deltas.
      
        This allows original spacing to apply in most cases, only changed
        AST items need initial delta positions.
      
      * Add DArrow to TrailingAnn
      
      * EPA Introduce HasTrailing in ExactPrint
      
         Use [TrailingAnn] in enterAnn and remove it from
         ExactPrint (LocatedN RdrName)
      
      * In HsDo, put TrailingAnns at top of LastStmt
      
      * EPA: do not convert comments to deltas when balancing.
      
      * EPA: deal with fallout from getMonoBind
      
      * EPA fix captureLineSpacing
      
      * EPA print any comments in the span before exiting it
      
      * EPA: Add comments to AnchorOperation
      
      * EPA: remove AnnEofComment, it is no longer used
      
      Updates Haddock submodule
      81fb8885
  8. 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
  9. Jun 21, 2023
    • Finley McIlwaine's avatar
      Memory usage fixes for Haddock · 3d1d42b7
      Finley McIlwaine authored and Ben Gamari's avatar Ben Gamari committed
      - Do not include `mi_globals` in the `NoBackend` backend. It was only included
        for Haddock, but Haddock does not actually need it. This causes a 200MB
        reduction in max residency when generating haddocks on the Agda codebase
        (roughly 1GB to 800MB).
      
      - Make haddock_{parser,renamer}_perf tests more accurate by forcing docs to
        be written to interface files using `-fwrite-interface`
      
      Bumps haddock submodule.
      
      Metric Decrease:
          haddock.base
      3d1d42b7
  10. Jun 07, 2023
    • Vladislav Zavialov's avatar
      Invisible binders in type declarations (#22560) · 4aea0a72
      Vladislav Zavialov authored
      
      This patch implements @k-binders introduced in GHC Proposal #425
      and guarded behind the TypeAbstractions extension:
      
      	type D :: forall k j. k -> j -> Type
      	data D @k @j a b = ...
      	       ^^ ^^
      
      To represent the new syntax, we modify LHsQTyVars as follows:
      
      	-  hsq_explicit :: [LHsTyVarBndr () pass]
      	+  hsq_explicit :: [LHsTyVarBndr (HsBndrVis pass) pass]
      
      HsBndrVis is a new data type that records the distinction between
      type variable binders written with and without the @ sign:
      
      	data HsBndrVis pass
      	  = HsBndrRequired
      	  | HsBndrInvisible (LHsToken "@" pass)
      
      The rest of the patch updates GHC, template-haskell, and haddock
      to handle the new syntax.
      
      Parser:
        The PsErrUnexpectedTypeAppInDecl error message is removed.
        The syntax it used to reject is now permitted.
      
      Renamer:
        The @ sign does not affect the scope of a binder, so the changes to
        the renamer are minimal.  See rnLHsTyVarBndrVisFlag.
      
      Type checker:
        There are three code paths that were updated to deal with the newly
        introduced invisible type variable binders:
      
          1. checking SAKS: see kcCheckDeclHeader_sig, matchUpSigWithDecl
          2. checking CUSK: see kcCheckDeclHeader_cusk
          3. inference: see kcInferDeclHeader, rejectInvisibleBinders
      
        Helper functions bindExplicitTKBndrs_Q_Skol and bindExplicitTKBndrs_Q_Tv
        are generalized to work with HsBndrVis.
      
      Updates the haddock submodule.
      
      Metric Increase:
          MultiLayerModulesTH_OneShot
      
      Co-authored-by: default avatarSimon Peyton Jones <simon.peytonjones@gmail.com>
      4aea0a72
  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. Apr 20, 2023
  13. Dec 23, 2022
  14. Dec 09, 2022
  15. Nov 29, 2022
  16. Oct 22, 2022
  17. Sep 27, 2022
  18. 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
  19. 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
  20. Jul 03, 2022
  21. May 24, 2022
    • Greg Steuck's avatar
      Fix haddock_*_perf tests on non-GNU-grep systems · 3b8c413a
      Greg Steuck authored and Marge Bot's avatar Marge Bot committed
      Using regexp pattern requires `egrep` and straight up `+`.  The
      haddock_parser_perf and haddock_renamer_perf tests now pass on
      OpenBSD. They previously incorrectly parsed the files and awk
      complained about invalid syntax.
      3b8c413a
  22. Apr 08, 2022
  23. 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
  24. Dec 01, 2021
  25. Nov 02, 2021
    • Alan Zimmerman's avatar
      EPA: Get rid of bare SrcSpan's in the ParsedSource · 39eed84c
      Alan Zimmerman authored
      The ghc-exactPrint library has had to re-introduce the relatavise
      phase.
      
      This is needed if you change the length of an identifier and want the
      layout to be preserved afterwards.
      
      It is not possible to relatavise a bare SrcSpan, so introduce `SrcAnn
      NoEpAnns` for them instead.
      
      Updates haddock submodule.
      39eed84c
  26. Oct 24, 2021
  27. Oct 13, 2021
  28. Oct 05, 2021
    • Vladislav Zavialov's avatar
      Bespoke TokenLocation data type · a7629334
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      The EpaAnnCO we were using contained an Anchor instead of EpaLocation,
      making it harder to work with.
      
      At the same time, using EpaLocation by itself isn't possible either,
      as we may have tokens without location information.
      
      Hence the new data type:
      	data TokenLocation = NoTokenLoc
      	                   | TokenLoc !EpaLocation
      a7629334
  29. Aug 05, 2021
  30. Jun 17, 2021
  31. May 20, 2021
  32. Apr 19, 2021
    • Alan Zimmerman's avatar
      EPA: cleanups after the merge · 0619fb0f
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      Remove EpaAnn type synonym, rename EpaAnn' to EpaAnn.
      Closes #19705
      
      Updates haddock submodule
      
      --
      
      Change
        data EpaAnchor = AR RealSrcSpan
                       | AD DeltaPos
      
      To instead be
        data EpaAnchor = AnchorReal RealSrcSpan
                       | AnchorDelta DeltaPos
      
      Closes #19699
      
      --
      
      Change
        data DeltaPos =
          DP
            { deltaLine   :: !Int,
              deltaColumn :: !Int
            }
      
      To instead be
        data DeltaPos
          = SameLine { deltaColumn :: !Int }
          | DifferentLine { deltaLine :: !Int, startColumn :: !Int }
      
      Closes #19698
      
      --
      
      Also some clean-ups of unused parts of check-exact.
      0619fb0f
  33. Mar 31, 2021
  34. Mar 20, 2021
  35. Mar 01, 2021
  36. Nov 06, 2020
    • Ryan Scott's avatar
      Replace HsImplicitBndrs with HsOuterTyVarBndrs · e07e383a
      Ryan Scott authored and Marge Bot's avatar Marge Bot committed
      
      This refactors the GHC AST to remove `HsImplicitBndrs` and replace it with
      `HsOuterTyVarBndrs`, a type which records whether the outermost quantification
      in a type is explicit (i.e., with an outermost, invisible `forall`) or
      implicit. As a result of this refactoring, it is now evident in the AST where
      the `forall`-or-nothing rule applies: it's all the places that use
      `HsOuterTyVarBndrs`. See the revamped `Note [forall-or-nothing rule]` in
      `GHC.Hs.Type` (previously in `GHC.Rename.HsType`).
      
      Moreover, the places where `ScopedTypeVariables` brings lexically scoped type
      variables into scope are a subset of the places that adhere to the
      `forall`-or-nothing rule, so this also makes places that interact with
      `ScopedTypeVariables` easier to find. See the revamped
      `Note [Lexically scoped type variables]` in `GHC.Hs.Type` (previously in
      `GHC.Tc.Gen.Sig`).
      
      `HsOuterTyVarBndrs` are used in type signatures (see `HsOuterSigTyVarBndrs`)
      and type family equations (see `HsOuterFamEqnTyVarBndrs`). The main difference
      between the former and the latter is that the former cares about specificity
      but the latter does not.
      
      There are a number of knock-on consequences:
      
      * There is now a dedicated `HsSigType` type, which is the combination of
        `HsOuterSigTyVarBndrs` and `HsType`. `LHsSigType` is now an alias for an
        `XRec` of `HsSigType`.
      * Working out the details led us to a substantial refactoring of
        the handling of explicit (user-written) and implicit type-variable
        bindings in `GHC.Tc.Gen.HsType`.
      
        Instead of a confusing family of higher order functions, we now
        have a local data type, `SkolemInfo`, that controls how these
        binders are kind-checked.
      
        It remains very fiddly, not fully satisfying. But it's better
        than it was.
      
      Fixes #16762. Bumps the Haddock submodule.
      
      Co-authored-by: default avatarSimon Peyton Jones <simonpj@microsoft.com>
      Co-authored-by: Richard Eisenberg's avatarRichard Eisenberg <rae@richarde.dev>
      Co-authored-by: default avatarZubin Duggal <zubin@cmi.ac.in>
      e07e383a
  37. Oct 30, 2020
    • Ryan Scott's avatar
      Split HsConDecl{H98,GADT}Details · 31fcb55f
      Ryan Scott authored and Marge Bot's avatar Marge Bot committed
      Haskell98 and GADT constructors both use `HsConDeclDetails`, which includes
      `InfixCon`. But `InfixCon` is never used for GADT constructors, which results
      in an awkward unrepresentable state. This removes the unrepresentable state by:
      
      * Renaming the existing `HsConDeclDetails` synonym to `HsConDeclH98Details`,
        which emphasizes the fact that it is now only used for Haskell98-style data
        constructors, and
      * Creating a new `HsConDeclGADTDetails` data type with `PrefixConGADT` and
        `RecConGADT` constructors that closely resemble `PrefixCon` and `InfixCon`
        in `HsConDeclH98Details`. The key difference is that `HsConDeclGADTDetails`
        lacks any way to represent infix constructors.
      
      The rest of the patch is refactoring to accommodate the new structure of
      `HsConDecl{H98,GADT}Details`. Some highlights:
      
      * The `getConArgs` and `hsConDeclArgTys` functions have been removed, as
        there is no way to implement these functions uniformly for all
        `ConDecl`s. For the most part, their previous call sites now
        pattern match on the `ConDecl`s directly and do different things for
        `ConDeclH98`s and `ConDeclGADT`s.
      
        I did introduce one new function to make the transition easier:
        `getRecConArgs_maybe`, which extracts the arguments from a `RecCon(GADT)`.
        This is still possible since `RecCon(GADT)`s still use the same representation
        in both `HsConDeclH98Details` and `HsConDeclGADTDetails`, and since the
        pattern that `getRecConArgs_maybe` implements is used in several places,
        I thought it worthwhile to factor it out into its own function.
      * Previously, the `con_args` fields in `ConDeclH98` and `ConDeclGADT` were
        both of type `HsConDeclDetails`. Now, the former is of type
        `HsConDeclH98Details`, and the latter is of type `HsConDeclGADTDetails`,
        which are distinct types. As a result, I had to rename the `con_args` field
        in `ConDeclGADT` to `con_g_args` to make it typecheck.
      
        A consequence of all this is that the `con_args` field is now partial, so
        using `con_args` as a top-level field selector is dangerous. (Indeed, Haddock
        was using `con_args` at the top-level, which caused it to crash at runtime
        before I noticed what was wrong!) I decided to add a disclaimer in the 9.2.1
        release notes to advertise this pitfall.
      
      Fixes #18844. Bumps the `haddock` submodule.
      31fcb55f
  38. Oct 20, 2020
    • Alan Zimmerman's avatar
      API Annotations: Keep track of unicode for linear arrow notation · ea736839
      Alan Zimmerman authored
      The linear arrow can be parsed as `%1 ->` or a direct single token unicode
      equivalent.
      
      Make sure that this distinction is captured in the parsed AST by using
      IsUnicodeSyntax where it appears, and introduce a new API Annotation,
      AnnMult to represent its location when unicode is not used.
      
      Updated haddock submodule
      ea736839
Loading