Skip to content
Snippets Groups Projects
  1. Feb 13, 2024
  2. Feb 08, 2024
    • Jade's avatar
      Improve Monad, Functor & Applicative docs · 762b2120
      Jade authored and Matthew Pickering's avatar Matthew Pickering committed
      This patch aims to improve the documentation of Functor, Applicative,
      Monad and related symbols. The main goal is to make it more consistent
      and make accessible. See also: !10979 (closed) and !10985 (closed)
      
      Ticket #17929
      
      Updates haddock submodule
      762b2120
    • 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. Feb 03, 2024
    • Apoorv Ingle's avatar
      Expand `do` blocks right before typechecking using the `HsExpansion` philosophy. · 5ff7cc26
      Apoorv Ingle authored
      - Fixes #18324 #20020 #23147 #22788 #15598 #22086 #21206
      
      - The change is detailed in
        - Note [Expanding HsDo with HsExpansion] in `GHC.Tc.Gen.Do`
        - Note [Doing HsExpansion in the Renamer vs Typechecker] in `GHC.Rename.Expr`
               expains the rational of doing expansions in type checker as opposed to in the renamer
      
      - Adds new datatypes:
        - `GHC.Hs.Expr.XXExprGhcRn`: new datatype makes this expansion work easier
          1. Expansion bits for Expressions, Statements and Patterns in (`ExpandedThingRn`)
          2. `PopErrCtxt` a special GhcRn Phase only artifcat to pop the previous error message in the error context stack
      
        - `GHC.Basic.Origin` now tracks the reason for expansion in case of Generated
          This is useful for type checking cf. `GHC.Tc.Gen.Expr.tcExpr` case for `HsLam`
      
        - Kills `HsExpansion` and `HsExpanded` as we have inlined them in `XXExprGhcRn` and `XXExprGhcTc`
      
      - Ensures warnings such as
        1. Pattern match checks
        2. Failable patterns
        3. non-() return in body statements are preserved
      
      - Kill `HsMatchCtxt` in favor of `TcMatchAltChecker`
      
      - Testcases:
        * T18324 T20020 T23147 T22788 T15598 T22086
        * T23147b (error message check),
        * DoubleMatch (match inside a match for pmc check)
        * pattern-fails (check pattern match with non-refutable pattern, eg. newtype)
        * Simple-rec (rec statements inside do statment)
        * T22788 (code snippet from #22788)
        * DoExpanion1 (Error messages for body statments)
        * DoExpansion2 (Error messages for bind statements)
        * DoExpansion3 (Error messages for let statements)
      
      Also repoint haddock to the right submodule so that the test (haddockHypsrcTest) pass
      
      Metric Increase 'compile_time/bytes allocated':
          T9020
      
      The testcase is a pathalogical example of a `do`-block with many statements that do nothing.
      Given that we are expanding the statements into function binds, we will have to bear
      a (small) 2% cost upfront in the compiler to unroll the statements.
      5ff7cc26
  4. Feb 01, 2024
    • Andrei Borzenkov's avatar
      Namespacing for WARNING/DEPRECATED pragmas (#24396) · 151dda4e
      Andrei Borzenkov authored and Marge Bot's avatar Marge Bot committed
      New syntax for WARNING and DEPRECATED pragmas was added,
      namely namespace specifierss:
      
        namespace_spec ::= 'type' | 'data' | {- empty -}
      
        warning ::= warning_category namespace_spec namelist strings
      
        deprecation ::= namespace_spec namelist strings
      
      A new data type was introduced to represent these namespace specifiers:
      
        data NamespaceSpecifier =
          NoSpecifier |
          TypeNamespaceSpecifier (EpToken "type") |
          DataNamespaceSpecifier (EpToken "data")
      
      Extension field XWarning now contains this NamespaceSpecifier.
      
      lookupBindGroupOcc function was changed: it now takes NamespaceSpecifier
      and checks that the namespace of the found names matches the passed flag.
      With this change {-# WARNING data D "..." #-} pragma will only affect value
      namespace and {-# WARNING type D "..." #-} will only affect type
      namespace. The same logic is applicable to DEPRECATED pragmas.
      
      Finding duplicated warnings inside rnSrcWarnDecls now takes into
      consideration NamespaceSpecifier flag to allow warnings with the
      same names that refer to different namespaces.
      151dda4e
  5. Jan 26, 2024
  6. Jan 24, 2024
  7. Jan 20, 2024
  8. Jan 19, 2024
  9. Jan 07, 2024
  10. Dec 20, 2023
    • Ben Gamari's avatar
      Fix thunk update ordering · 9a52ae46
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      Previously we attempted to ensure soundness of concurrent thunk update
      by synchronizing on the access of the thunk's info table pointer field.
      This was believed to be sufficient since the indirectee (which may
      expose a closure allocated by another core) would not be examined
      until the info table pointer update is complete.
      
      However, it turns out that this can result in data races in the presence
      of multiple threads racing a update a single thunk. For instance,
      consider this interleaving under the old scheme:
      
                  Thread A                             Thread B
                  ---------                            ---------
          t=0     Enter t
            1     Push update frame
            2     Begin evaluation
      
            4     Pause thread
            5     t.indirectee=tso
            6     Release t.info=BLACKHOLE
      
            7     ... (e.g. GC)
      
            8     Resume thread
            9     Finish evaluation
            10    Relaxed t.indirectee=x
      
            11                                         Load t.info
            12                                         Acquire fence
            13                                         Inspect t.indirectee
      
            14    Release t.info=BLACKHOLE
      
      Here Thread A enters thunk `t` but is soon paused, resulting in `t`
      being lazily blackholed at t=6. Then, at t=10 Thread A finishes
      evaluation and updates `t.indirectee` with a relaxed store.
      
      Meanwhile, Thread B enters the blackhole. Under the old scheme this
      would introduce an acquire-fence but this would only synchronize with
      Thread A at t=6. Consequently, the result of the evaluation, `x`, is not
      visible to Thread B, introducing a data race.
      
      We fix this by treating the `indirectee` field as we do all other
      mutable fields. This means we must always access this field with
      acquire-loads and release-stores.
      
      See #23185.
      9a52ae46
  11. Dec 13, 2023
  12. Dec 11, 2023
    • Arnaud Spiwack's avatar
      Linear let and where bindings · 8e0446df
      Arnaud Spiwack authored
      For expediency, the initial implementation of linear types in GHC
      made it so that let and where binders would always be considered
      unrestricted. This was rather unpleasant, and probably a big obstacle
      to adoption. At any rate, this was not how the proposal was designed.
      
      This patch fixes this infelicity. It was surprisingly difficult to
      build, which explains, in part, why it took so long to materialise.
      
      As of this patch, let or where bindings marked with %1 will be
      linear (respectively %p for an arbitrary multiplicity p). Unmarked let
      will infer their multiplicity.
      
      Here is a prototypical example of program that used to be rejected and
      is accepted with this patch:
      
      ```haskell
      f :: A %1 -> B
      g :: B %1 -> C
      
      h :: A %1 -> C
      h x = g y
        where
          y = f x
      ```
      
      Exceptions:
      - Recursive let are unrestricted, as there isn't a clear semantics of
        what a linear recursive binding would be.
      - Destructive lets with lazy bindings are unrestricted, as their
        desugaring isn't linear (see also #23461).
      - (Strict) destructive lets with inferred polymorphic type are
        unrestricted. Because the desugaring isn't linear (See #18461
        down-thread).
      
      Closes #18461 and #18739
      
      Co-authored-by: @jackohughes
      8e0446df
  13. 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
  14. 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
  15. 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
  16. Nov 23, 2023
    • Alan Zimmerman's avatar
      EPA: empty tup_tail has noAnn · d2733a05
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      In Parser.y, the tup_tail rule had the following option
                | {- empty -} %shift   { return [Left noAnn] }
      
      Once this works through PostProcess.hs, it means we add an extra
      Missing constructor if the last item was a comma.
      
      Change the annotation type to a Bool to indicate this, and use the
      EpAnn Anchor for the print location for the others.
      d2733a05
  17. Nov 22, 2023
  18. 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
  19. Nov 18, 2023
  20. Nov 15, 2023
    • Rodrigo Mesquita's avatar
      darwin: Fix single_module is obsolete warning · e6c803f7
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      In XCode 15's linker, -single_module is the default and otherwise
      passing it as a flag results in a warning being raised:
      
          ld: warning: -single_module is obsolete
      
      This patch fixes this warning by, at configure time, determining whether
      the linker supports -single_module (which is likely false for all
      non-darwin linkers, and true for darwin linkers in previous versions of
      macOS), and using that information at runtime to decide to pass or not
      the flag in the invocation.
      
      Fixes #24168
      e6c803f7
    • Rodrigo Mesquita's avatar
      Suppress duplicate librares linker warning of new macOS linker · e98051a5
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      Fixes #24167
      
      XCode 15 introduced a new linker which warns on duplicate libraries being
      linked. To disable this warning, we pass -Wl,-no_warn_duplicate_libraries as
      suggested by Brad King in CMake issue #25297.
      
      This flag isn't necessarily available to other linkers on darwin, so we must
      only configure it into the CC linker arguments if valid.
      e98051a5
  21. Nov 12, 2023
    • Alan Zimmerman's avatar
      EPA: get rid of AnchorOperation · a7492048
      Alan Zimmerman authored
      Now that the Anchor type is an alias for EpaLocation, remove
      AnchorOperation.
      
      Updates haddock submodule
      a7492048
    • 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
  22. Nov 10, 2023
    • PHO's avatar
      Don't assume the current locale is *.UTF-8, set the encoding explicitly · 52c0fc69
      PHO authored and Marge Bot's avatar Marge Bot committed
      primops.txt contains Unicode characters:
      > LC_ALL=C ./genprimopcode --data-decl < ./primops.txt
      > genprimopcode: <stdin>: hGetContents: invalid argument (cannot decode byte sequence starting from 226)
      
      Hadrian must also avoid using readFile' to read primops.txt because it
      tries to decode the file with a locale-specific encoding.
      52c0fc69
  23. Nov 07, 2023
  24. 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
  25. Oct 31, 2023
    • Alan Zimmerman's avatar
      EPA: print doc comments as normal comments · 723bc352
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      And ignore the ones allocated in haddock processing.
      
      It does not guarantee that every original haddock-like comment appears
      in the output, as it discards ones that have no legal attachment point.
      
      closes #23459
      723bc352
  26. Oct 10, 2023
Loading