
[Git][ghc/ghc][master] 2 commits: Extend record-selector usage ticking to all binds using a record field
by Marge Bot (@marge-bot) 13 Aug '25
by Marge Bot (@marge-bot) 13 Aug '25
13 Aug '25
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
62899117 by Florian Ragwitz at 2025-08-13T21:01:34-04:00
Extend record-selector usage ticking to all binds using a record field
This extends the previous handling of ticking for RecordWildCards and
NamedFieldPuns to all var bindings that involve record selectors.
Note that certain patterns such as `Foo{foo = 42}` will currently not tick the
`foo` selector, as ticking is triggered by `HsVar`s.
Closes #26191.
- - - - -
b37b3af7 by Florian Ragwitz at 2025-08-13T21:01:34-04:00
Add release notes for 9.16.1 and move description of latest HPC changes there.
- - - - -
6 changed files:
- compiler/GHC/HsToCore/Ticks.hs
- − docs/users_guide/9.14.1-notes.rst
- + docs/users_guide/9.16.1-notes.rst
- docs/users_guide/release-notes.rst
- testsuite/tests/hpc/recsel/recsel.hs
- testsuite/tests/hpc/recsel/recsel.stdout
Changes:
=====================================
compiler/GHC/HsToCore/Ticks.hs
=====================================
@@ -251,7 +251,7 @@ addTickLHsBind (L pos (XHsBindsLR bind@(AbsBinds { abs_binds = binds
add_rec_sels env =
env{ recSelBinds = recSelBinds env `extendVarEnvList`
- [ (abe_mono, abe_poly)
+ [ (abe_mono, unitDVarSet abe_poly)
| ABE{ abe_poly, abe_mono } <- abs_exports
, RecSelId{} <- [idDetails abe_poly] ] }
@@ -270,8 +270,8 @@ addTickLHsBind (L pos (funBind@(FunBind { fun_id = L _ id, fun_matches = matches
case tickish of { ProfNotes | inline -> return (L pos funBind); _ -> do
-- See Note [Record-selector ticks]
- selTick <- recSelTick id
- case selTick of { Just tick -> tick_rec_sel tick; _ -> do
+ selTicks <- recSelTick id
+ case selTicks of { Just ticks -> tick_rec_sel ticks; _ -> do
(fvs, mg) <-
getFreeVars $
@@ -303,8 +303,8 @@ addTickLHsBind (L pos (funBind@(FunBind { fun_id = L _ id, fun_matches = matches
} }
where
-- See Note [Record-selector ticks]
- tick_rec_sel tick =
- pure $ L pos $ funBind { fun_ext = second (tick :) (fun_ext funBind) }
+ tick_rec_sel ticks =
+ pure $ L pos $ funBind { fun_ext = second (ticks ++) (fun_ext funBind) }
-- Note [Record-selector ticks]
@@ -319,9 +319,8 @@ addTickLHsBind (L pos (funBind@(FunBind { fun_id = L _ id, fun_matches = matches
-- coverage purposes to improve the developer experience.
--
-- This is done by keeping track of which 'Id's are effectively bound to
--- record fields (using NamedFieldPuns or RecordWildCards) in 'TickTransEnv's
--- 'recSelBinds', and making 'HsVar's corresponding to those fields tick the
--- appropriate box when executed.
+-- record fields in 'TickTransEnv's 'recSelBinds', and making 'HsVar's
+-- corresponding to those fields tick the appropriate box when executed.
--
-- To enable that, we also treat 'FunBind's for record selector functions
-- specially. We only create a TopLevelBox for the record selector function,
@@ -329,11 +328,11 @@ addTickLHsBind (L pos (funBind@(FunBind { fun_id = L _ id, fun_matches = matches
-- of ticks for the same record selector, and is done by not recursing into
-- the fun_matches match group for record selector functions.
--
+-- Note that due to the use of 'HsVar's for ticking, certain patterns such
+-- as `Foo{foo = 42}` will not cause the `foo` selector to be ticked.
+--
-- This scheme could be extended further in the future, making coverage for
--- constructor fields (named or even positional) mean that the field was
--- accessed at run-time. For the time being, we only cover NamedFieldPuns and
--- RecordWildCards binds to cover most practical use-cases while keeping it
--- simple.
+-- positional constructor fields mean that the field was accessed at run-time.
-- TODO: Revisit this
addTickLHsBind (L pos (pat@(PatBind { pat_lhs = lhs
@@ -519,7 +518,7 @@ addTickHsExpr :: HsExpr GhcTc -> TM (HsExpr GhcTc)
-- See Note [Record-selector ticks]
addTickHsExpr e@(HsVar _ (L _ id)) =
freeVar id >> recSelTick id >>= pure . maybe e wrap
- where wrap tick = XExpr . HsTick tick . noLocA $ e
+ where wrap = foldr (\tick -> XExpr . HsTick tick . noLocA) e
addTickHsExpr e@(HsIPVar {}) = return e
addTickHsExpr e@(HsOverLit {}) = return e
addTickHsExpr e@(HsOverLabel{}) = return e
@@ -1086,7 +1085,7 @@ data TickTransEnv = TTE { fileName :: FastString
, blackList :: Set RealSrcSpan
, this_mod :: Module
, tickishType :: TickishType
- , recSelBinds :: IdEnv Id
+ , recSelBinds :: IdEnv DVarSet
}
-- deriving Show
@@ -1241,11 +1240,12 @@ allocTickBox boxLabel countEntries topOnly pos m
tickish <- mkTickish boxLabel countEntries topOnly pos fvs (declPath env)
return (this_loc (XExpr $ HsTick tickish $ this_loc e))
-recSelTick :: Id -> TM (Maybe CoreTickish)
+recSelTick :: Id -> TM (Maybe [CoreTickish])
recSelTick id = ifDensity TickForCoverage maybe_tick (pure Nothing)
where
maybe_tick = getEnv >>=
- maybe (pure Nothing) tick . (`lookupVarEnv` id) . recSelBinds
+ maybe (pure Nothing) tick_all . (`lookupVarEnv` id) . recSelBinds
+ tick_all = fmap (Just . catMaybes) . mapM tick . dVarSetElems
tick sel = getState >>=
maybe (alloc sel) (pure . Just) . (`lookupVarEnv` sel) . recSelTicks
alloc sel = allocATickBox (box sel) False False (getSrcSpan sel) noFVs
@@ -1367,7 +1367,7 @@ class CollectBinders a where
--
-- See Note [Record-selector ticks].
class CollectFldBinders a where
- collectFldBinds :: a -> IdEnv Id
+ collectFldBinds :: a -> IdEnv DVarSet
instance CollectBinders (LocatedA (Pat GhcTc)) where
collectBinds = collectPatBinders CollNoDictBinders
@@ -1385,41 +1385,37 @@ instance (CollectFldBinders a) => CollectFldBinders [a] where
instance (CollectFldBinders e) => CollectFldBinders (GenLocated l e) where
collectFldBinds = collectFldBinds . unLoc
instance CollectFldBinders (Pat GhcTc) where
- collectFldBinds ConPat{ pat_args = RecCon HsRecFields{ rec_flds, rec_dotdot } } =
- collectFldBinds rec_flds `plusVarEnv` plusVarEnvList (zipWith fld_bnds [0..] rec_flds)
- where n_explicit | Just (L _ (RecFieldsDotDot n)) <- rec_dotdot = n
- | otherwise = length rec_flds
- fld_bnds n (L _ HsFieldBind{ hfbLHS = L _ FieldOcc{ foLabel = L _ sel }
- , hfbRHS = L _ (VarPat _ (L _ var))
- , hfbPun })
- | hfbPun || n >= n_explicit = unitVarEnv var sel
- fld_bnds _ _ = emptyVarEnv
- collectFldBinds ConPat{ pat_args = PrefixCon pats } = collectFldBinds pats
- collectFldBinds ConPat{ pat_args = InfixCon p1 p2 } = collectFldBinds [p1, p2]
- collectFldBinds (LazyPat _ pat) = collectFldBinds pat
- collectFldBinds (BangPat _ pat) = collectFldBinds pat
- collectFldBinds (AsPat _ _ pat) = collectFldBinds pat
- collectFldBinds (ViewPat _ _ pat) = collectFldBinds pat
- collectFldBinds (ParPat _ pat) = collectFldBinds pat
- collectFldBinds (ListPat _ pats) = collectFldBinds pats
- collectFldBinds (TuplePat _ pats _) = collectFldBinds pats
- collectFldBinds (SumPat _ pats _ _) = collectFldBinds pats
- collectFldBinds (SigPat _ pat _) = collectFldBinds pat
- collectFldBinds (XPat exp) = collectFldBinds exp
- collectFldBinds VarPat{} = emptyVarEnv
- collectFldBinds WildPat{} = emptyVarEnv
- collectFldBinds OrPat{} = emptyVarEnv
- collectFldBinds LitPat{} = emptyVarEnv
- collectFldBinds NPat{} = emptyVarEnv
- collectFldBinds NPlusKPat{} = emptyVarEnv
- collectFldBinds SplicePat{} = emptyVarEnv
- collectFldBinds EmbTyPat{} = emptyVarEnv
- collectFldBinds InvisPat{} = emptyVarEnv
-instance (CollectFldBinders r) => CollectFldBinders (HsFieldBind l r) where
- collectFldBinds = collectFldBinds . hfbRHS
-instance CollectFldBinders XXPatGhcTc where
- collectFldBinds (CoPat _ pat _) = collectFldBinds pat
- collectFldBinds (ExpansionPat _ pat) = collectFldBinds pat
+ collectFldBinds = go emptyDVarSet where
+ go sels ConPat{ pat_args = RecCon HsRecFields{ rec_flds } } =
+ plusVarEnvList (map fld_binds rec_flds)
+ where fld_binds (L _ HsFieldBind{ hfbLHS = L _ FieldOcc{ foLabel = L _ sel }
+ , hfbRHS = L _ rhs })
+ = go (extendDVarSet sels sel) rhs
+ go sels ConPat{ pat_args = PrefixCon ps } =
+ plusVarEnvList (map (go sels . unLoc) ps)
+ go sels ConPat{ pat_args = InfixCon (L _ p1) (L _ p2) } =
+ go sels p1 `plusVarEnv` go sels p2
+ go sels (VarPat _ (L _ var)) | isEmptyDVarSet sels = emptyVarEnv
+ | otherwise = unitVarEnv var sels
+ go sels (LazyPat _ (L _ p)) = go sels p
+ go sels (BangPat _ (L _ p)) = go sels p
+ go sels (AsPat _ _ (L _ p)) = go sels p
+ go sels (ViewPat _ _ (L _ p)) = go sels p
+ go sels (ParPat _ (L _ p)) = go sels p
+ go sels (SigPat _ (L _ p) _) = go sels p
+ go sels (SumPat _ (L _ p) _ _) = go sels p
+ go sels (XPat (CoPat _ p _)) = go sels p
+ go sels (XPat (ExpansionPat _ p)) = go sels p
+ go sels (ListPat _ ps) = plusVarEnvList (map (go sels . unLoc) ps)
+ go sels (TuplePat _ ps _) = plusVarEnvList (map (go sels . unLoc) ps)
+ go _ WildPat{} = emptyVarEnv
+ go _ OrPat{} = emptyVarEnv
+ go _ LitPat{} = emptyVarEnv
+ go _ NPat{} = emptyVarEnv
+ go _ NPlusKPat{} = emptyVarEnv
+ go _ SplicePat{} = emptyVarEnv
+ go _ EmbTyPat{} = emptyVarEnv
+ go _ InvisPat{} = emptyVarEnv
instance CollectFldBinders (HsLocalBinds GhcTc) where
collectFldBinds (HsValBinds _ bnds) = collectFldBinds bnds
collectFldBinds HsIPBinds{} = emptyVarEnv
@@ -1430,9 +1426,9 @@ instance CollectFldBinders (HsValBinds GhcTc) where
instance CollectFldBinders (HsBind GhcTc) where
collectFldBinds PatBind{ pat_lhs } = collectFldBinds pat_lhs
collectFldBinds (XHsBindsLR AbsBinds{ abs_exports, abs_binds }) =
- mkVarEnv [ (abe_poly, sel)
+ mkVarEnv [ (abe_poly, sels)
| ABE{ abe_poly, abe_mono } <- abs_exports
- , Just sel <- [lookupVarEnv monos abe_mono] ]
+ , Just sels <- [lookupVarEnv monos abe_mono] ]
where monos = collectFldBinds abs_binds
collectFldBinds VarBind{} = emptyVarEnv
collectFldBinds FunBind{} = emptyVarEnv
=====================================
docs/users_guide/9.14.1-notes.rst deleted
=====================================
@@ -1,290 +0,0 @@
-.. _release-9-14-1:
-
-Version 9.14.1
-==============
-
-The significant changes to the various parts of the compiler are listed in the
-following sections. See the `migration guide
-<https://gitlab.haskell.org/ghc/ghc/-/wikis/migration/9.14>`_ on the GHC Wiki
-for specific guidance on migrating programs to this release.
-
-Language
-~~~~~~~~
-
-* `GHC proposal 493: allow expressions in SPECIALISE pragmas <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0493-s…>`_
- has been implemented. SPECIALISE pragmas now allow arbitrary expressions such as: ::
-
- {-# SPECIALISE f @Int False :: Int -> Char #-}
-
- The ability to specify multiple specialisations in a single SPECIALISE pragma,
- with syntax of the form (note the comma between the type signatures): ::
-
- {-# SPECIALISE g : Int -> Int, Float -> Float #-}
-
- has been deprecated, and is scheduled to be removed in GHC 9.18.
- This deprecation is controlled by the newly introduced ``-Wdeprecated-pragmas``
- flag in ``-Wdefault``.
-
-* ``-Wincomplete-record-selectors`` is now part of `-Wall`, as specified
- by `GHC Proposal 516: add warning for incomplete record selectors <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0516-i…>`_.
- Hence, if a library is compiled with ``-Werror``, compilation may now fail. Solution: fix the library.
- Workaround: add ``-Werror=no-incomplete-record-selectors``.
-
- Note that this warning is at least
- as serious as a warning about missing patterns from a function definition, perhaps even
- more so, since it is invisible in the source program.
-
-* The combination of :extension:`ScopedTypeVariables` and :extension:`TypeApplications`
- no longer enables type applications in patterns, which now always requires
- :extension:`TypeAbstractions`. The warning flag``deprecated-type-abstractions``
- has also been removed from the compiler.
-
-* :extension:`OverloadedRecordUpdate` now passes the arguments to a ``setField`` function
- in the flipped order, as specified by `GHC Proposal 583: HasField redesign <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0583-h…>`_.
-
- Previously GHC expected ``setField`` to have this type: ::
-
- setField :: forall (fld :: Symbol) a r. r -> a -> r
-
- And that's what GHC expects now: ::
-
- setField :: forall (fld :: Symbol) a r. a -> r -> r
-
- That will break the combination of :extension:`OverloadedRecordUpdate` with :extension:`RebindableSyntax`.
-
-* Multiline strings are now accepted in foreign imports. (#25157)
-
-* GHC now does a better job at inferring types in calls to ``coerce``: instead of
- complaining about ambiguous type variables, GHC will consider that such type
- variables are determined by the ``Coercible`` constraints they appear in.
-
-* With :extension:`LinearTypes` record fields can now be non-linear. This means that
- the following record declaration is now valid:
-
- ::
-
- data Record = Rec { x %'Many :: Int, y :: Char }
-
- This causes the constructor to have type ``Rec :: Int %'Many -> Char %1 -> Record``.
-
-* The :extension:`ExplicitNamespaces` extension now allows the ``data``
- namespace specifier in import and export lists.
-
-* The ``-Wdata-kinds-tc`` warning has been deprecated, and the use of promoted
- data types in kinds is now an error (rather than a warning) unless the
- :extension:`DataKinds` extension is enabled. For example, the following code
- will be rejected unless :extension:`DataKinds` is on:
-
- import Data.Kind (Type)
- import GHC.TypeNats (Nat)
-
- -- Nat shouldn't be allowed here without DataKinds
- data Vec :: Nat -> Type -> Type
-
- (The ``-Wdata-kinds-tc`` warning was introduced in GHC 9.10 as part of a fix
- for an accidental oversight in which programs like the one above were
- mistakenly accepted without the use of :extension:`DataKinds`.)
-
-* The :extension:`MonadComprehensions` extension now implies :extension:`ParallelListComp` as was originally intended (see `Monad Comprehensions <https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/monad_comprehension…>`_).
-
-* In accordance with `GHC Proposal #281 <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0281-v…>`_,
- section 4.7 "Data constructors", the :extension:`RequiredTypeArguments`
- extension now allows visible forall in types of data constructors
- (:ghc-ticket:`25127`). The following declaration is now accepted by GHC:
-
- ::
-
- data T a where
- Typed :: forall a -> a -> T a
-
- See :ref:`visible-forall-in-gadts` for details.
-
-Compiler
-~~~~~~~~
-
-- An improved error message is introduced to refer users to the heap-controlling flags of the RTS when there is a heap overflow during compilation. (#25198)
-
-- The kind checker now does a better job of finding type family instances for
- use in the kinds of other declarations in the same module. This fixes a number
- of tickets:
- :ghc-ticket:`12088`, :ghc-ticket:`12239`, :ghc-ticket:`14668`, :ghc-ticket:`15561`,
- :ghc-ticket:`16410`, :ghc-ticket:`16448`, :ghc-ticket:`16693`, :ghc-ticket:`19611`,
- :ghc-ticket:`20875`, :ghc-ticket:`21172`, :ghc-ticket:`22257`, :ghc-ticket:`25238`,
- :ghc-ticket:`25834`.
-
-- The compiler no longer accepts invalid ``type`` namespace specifiers in
- subordinate import lists (:ghc-ticket:`22581`).
-
-- A new flag, :ghc-flag:`-Wuseless-specialisations`, controls warnings emitted when GHC
- determines that a SPECIALISE pragma would have no effect.
-
-- A new flag, :ghc-flag:`-Wrule-lhs-equalities`, controls warnings emitted for RULES
- whose left-hand side attempts to quantify over equality constraints that
- previous GHC versions accepted quantifying over. GHC will now drop such RULES,
- emitting a warning message controlled by this flag.
-
- This warning is intended to give visibility to the fact that the RULES that
- previous GHC versions generated in such circumstances could never fire.
-
-- A new flag, :ghc-flag:`-Wunusable-unpack-pragmas`, controls warnings emitted
- when GHC is unable to unpack a data constructor field annotated by the
- ``{-# UNPACK #-}`` pragma.
-
- Previous GHC versions issued this warning unconditionally. Now it is possible
- to disable it with ``-Wno-unusable-unpack-pragmas`` or turn it into an error
- with ``-Werror=unusable-unpack-pragmas``.
-
-- Introduce a new warning :ghc-flag:`-Wpattern-namespace-specifier` to detect
- uses of the now deprecated ``pattern`` namespace specifier in import/export
- lists. See `GHC Proposal #581, section 2.3 <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0581-n…>`_.
-
-- Code coverage (:ghc-flag:`-fhpc`) now treats uses of record fields via
- :extension:`RecordWildCards` or :extension:`NamedFieldPuns` as if the fields
- were accessed using the generated record selector functions, marking the fields
- as covered in coverage reports (:ghc-ticket:`17834`).
-
-- SIMD support in the X86 native code generator has been extended with 128-bit
- integer operations. Also, ``shuffleFloatX4#`` and ``shuffleDoubleX2#`` no longer
- require ``-mavx``.
-
-- JSON diagnostics produced with (:ghc-flag:`-fdiagnostics-as-json`) now
- include the `rendered` diagnostics message, in the exact same format as what
- GHC would have produced without -fdiagnostics-as-json (including ANSI escape
- sequences).
-
-GHCi
-~~~~
-
-- :ghci-cmd:`:info` now outputs type declarations with @-binders that are
- considered semantically significant. See the documentation for :ghci-cmd:`:info`
- itself for a more detailed explanation.
-
-- GHCi errors and warnings now have their own numeric error codes that are
- displayed alongside the error.
-
-Runtime system
-~~~~~~~~~~~~~~
-
-- Add new runtime flag :rts-flag:`--optimistic-linking` which instructs the
- runtime linker to continue in the presence of unknown symbols. By default this
- flag is not passed, preserving previous behavior.
-
-Cmm
-~~~
-
-``base`` library
-~~~~~~~~~~~~~~~~
-
-``ghc-prim`` library
-~~~~~~~~~~~~~~~~~~~~
-
-``ghc`` library
-~~~~~~~~~~~~~~~
-
-* The `UnknownDiagnostic` constructor now takes an additional type argument
- for the type of hints corresponding to the diagnostic, and an additional
- value-level argument used for existential wrapping of the hints of the inner
- diagnostic.
-
-* Changes to the HPT and HUG interface:
-
- - `addToHpt` and `addListToHPT` were moved from `GHC.Unit.Home.ModInfo` to `GHC.Unit.Home.PackageTable` and deprecated in favour of `addHomeModInfoToHpt` and `addHomeModInfosToHpt`.
- - `UnitEnvGraph` and operations `unitEnv_lookup_maybe`, `unitEnv_foldWithKey, `unitEnv_singleton`, `unitEnv_adjust`, `unitEnv_insert`, `unitEnv_new` were moved from `GHC.Unit.Env` to `GHC.Unit.Home.Graph`.
- - The HomePackageTable (HPT) is now exported from `GHC.Unit.Home.PackageTable`,
- and is now backed by an IORef to avoid by construction very bad memory leaks.
- This means the API to the HPT now is for the most part in IO. For instance,
- `emptyHomePackageTable` and `addHomeModInfoToHpt` are now in IO.
- - `mkHomeUnitEnv` was moved to `GHC.Unit.Home.PackageTable`, and now takes two
- extra explicit arguments. To restore previous behaviour, pass `emptyUnitState`
- and `Nothing` as the first two arguments additionally.
- - `hugElts` was removed. Users should prefer `allUnits` to get the keys of the
- HUG (the typical use case), or `traverse` or `unitEnv_foldWithKey` in other
- cases.
-
-* Changes to `Language.Haskell.Syntax.Expr`
-
- - The `ParStmtBlock` list argument of the `ParStmt` constructor of `StmtLR` is now `NonEmpty`.
-
-* As part of the implementation of `GHC proposal 493 <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0493-s…>`_,
- the `SpecSig` constructor of `Sig` has been deprecated. It is replaced by
- the constructor `SpecSigE` which supports expressions at the head, rather than
- a lone variable.
-
-``ghc-heap`` library
-~~~~~~~~~~~~~~~~~~~~
-
-* The functions `getClosureInfoTbl_maybe`, `getClosureInfoTbl`,
- `getClosurePtrArgs` and `getClosurePtrArgs_maybe` have been added to allow
- reading of the relevant Closure attributes without reliance on incomplete
- selectors.
-
-``ghc-experimental`` library
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-- ``ghc-experimental`` now exposes ``GHC.RTS.Flags`` and ``GHC.Stats`` as
- ``GHC.RTS.Flags.Experimental`` and ``GHC.Stats.Experimental``. These are
- *also* exposed in ``base``, however the ``base`` versions will be deprecated as
- part of the split base project. See `CLC proposal 289
- <https://github.com/haskell/core-libraries-committee/issues/289>`__.
- Downstream consumers of these flags are encouraged to migrate to the
- ``ghc-experimental`` versions.
-
-
-
-``template-haskell`` library
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-- As part of the implementation of `GHC proposal 493 <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0493-s…>`_,
- the ``SpecialiseP`` constructor of the Template Haskell ``Pragma`` type, as
- well as the helpers ``pragSpecD`` and ``pragSpecInlD``, have been deprecated.
-
- They are replaced, respectively, by ``SpecialiseEP``, ``pragSpecED`` and
- ``pragSpecInlED``.
-
-Included libraries
-~~~~~~~~~~~~~~~~~~
-
-The package database provided with this distribution also contains a number of
-packages other than GHC itself. See the changelogs provided with these packages
-for further change information.
-
-.. ghc-package-list::
-
- libraries/array/array.cabal: Dependency of ``ghc`` library
- libraries/base/base.cabal: Core library
- libraries/binary/binary.cabal: Dependency of ``ghc`` library
- libraries/bytestring/bytestring.cabal: Dependency of ``ghc`` library
- libraries/Cabal/Cabal/Cabal.cabal: Dependency of ``ghc-pkg`` utility
- libraries/Cabal/Cabal-syntax/Cabal-syntax.cabal: Dependency of ``ghc-pkg`` utility
- libraries/containers/containers/containers.cabal: Dependency of ``ghc`` library
- libraries/deepseq/deepseq.cabal: Dependency of ``ghc`` library
- libraries/directory/directory.cabal: Dependency of ``ghc`` library
- libraries/exceptions/exceptions.cabal: Dependency of ``ghc`` and ``haskeline`` library
- libraries/filepath/filepath.cabal: Dependency of ``ghc`` library
- compiler/ghc.cabal: The compiler itself
- libraries/ghci/ghci.cabal: The REPL interface
- libraries/ghc-boot/ghc-boot.cabal: Internal compiler library
- libraries/ghc-boot-th/ghc-boot-th.cabal: Internal compiler library
- libraries/ghc-compact/ghc-compact.cabal: Core library
- libraries/ghc-heap/ghc-heap.cabal: GHC heap-walking library
- libraries/ghc-prim/ghc-prim.cabal: Core library
- utils/haddock/haddock-api/haddock-api.cabal: Dependency of ``haddock`` executable
- utils/haddock/haddock-library/haddock-library.cabal: Dependency of ``haddock`` executable
- libraries/haskeline/haskeline.cabal: Dependency of ``ghci`` executable
- libraries/hpc/hpc.cabal: Dependency of ``hpc`` executable
- libraries/integer-gmp/integer-gmp.cabal: Core library
- libraries/mtl/mtl.cabal: Dependency of ``Cabal`` library
- libraries/parsec/parsec.cabal: Dependency of ``Cabal`` library
- libraries/pretty/pretty.cabal: Dependency of ``ghc`` library
- libraries/process/process.cabal: Dependency of ``ghc`` library
- libraries/stm/stm.cabal: Dependency of ``haskeline`` library
- libraries/template-haskell/template-haskell.cabal: Core library
- libraries/terminfo/terminfo.cabal: Dependency of ``haskeline`` library
- libraries/text/text.cabal: Dependency of ``Cabal`` library
- libraries/time/time.cabal: Dependency of ``ghc`` library
- libraries/transformers/transformers.cabal: Dependency of ``ghc`` library
- libraries/unix/unix.cabal: Dependency of ``ghc`` library
- libraries/Win32/Win32.cabal: Dependency of ``ghc`` library
- libraries/xhtml/xhtml.cabal: Dependency of ``haddock`` executable
- libraries/os-string/os-string.cabal: Dependency of ``filepath`` library
- libraries/file-io/file-io.cabal: Dependency of ``directory`` library
=====================================
docs/users_guide/9.16.1-notes.rst
=====================================
@@ -0,0 +1,99 @@
+.. _release-9-16-1:
+
+Version 9.16.1
+==============
+
+The significant changes to the various parts of the compiler are listed in the
+following sections. See the `migration guide
+<https://gitlab.haskell.org/ghc/ghc/-/wikis/migration/9.16>`_ on the GHC Wiki
+for specific guidance on migrating programs to this release.
+
+Language
+~~~~~~~~
+
+Compiler
+~~~~~~~~
+
+- Code coverage's (:ghc-flag:`-fhpc`) treatment of record fields now extends
+ beyond record fields accessed via :extension:`RecordWildCards` and
+ :extension:`NamedFieldPuns`, and also handles access to nested record fields.
+ That is, in a pattern such as ``Foo{bar = Bar{baz = b}}`` both ``bar`` and
+ ``baz`` will now be marked as covered if ``b`` is evaluated. Note that this
+ currently only works when record fields (or values contained within them) are
+ bound to variables. The very similar pattern ``Foo{bar = Bar{baz = 42}}``
+ will will not yet mark ``bar`` or ``baz`` as covered.
+
+GHCi
+~~~~
+
+Runtime system
+~~~~~~~~~~~~~~
+
+Cmm
+~~~
+
+``base`` library
+~~~~~~~~~~~~~~~~
+
+``ghc-prim`` library
+~~~~~~~~~~~~~~~~~~~~
+
+``ghc`` library
+~~~~~~~~~~~~~~~
+
+``ghc-heap`` library
+~~~~~~~~~~~~~~~~~~~~
+
+``ghc-experimental`` library
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+``template-haskell`` library
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Included libraries
+~~~~~~~~~~~~~~~~~~
+
+The package database provided with this distribution also contains a number of
+packages other than GHC itself. See the changelogs provided with these packages
+for further change information.
+
+.. ghc-package-list::
+
+ libraries/array/array.cabal: Dependency of ``ghc`` library
+ libraries/base/base.cabal: Core library
+ libraries/binary/binary.cabal: Dependency of ``ghc`` library
+ libraries/bytestring/bytestring.cabal: Dependency of ``ghc`` library
+ libraries/Cabal/Cabal/Cabal.cabal: Dependency of ``ghc-pkg`` utility
+ libraries/Cabal/Cabal-syntax/Cabal-syntax.cabal: Dependency of ``ghc-pkg`` utility
+ libraries/containers/containers/containers.cabal: Dependency of ``ghc`` library
+ libraries/deepseq/deepseq.cabal: Dependency of ``ghc`` library
+ libraries/directory/directory.cabal: Dependency of ``ghc`` library
+ libraries/exceptions/exceptions.cabal: Dependency of ``ghc`` and ``haskeline`` library
+ libraries/filepath/filepath.cabal: Dependency of ``ghc`` library
+ compiler/ghc.cabal: The compiler itself
+ libraries/ghci/ghci.cabal: The REPL interface
+ libraries/ghc-boot/ghc-boot.cabal: Internal compiler library
+ libraries/ghc-boot-th/ghc-boot-th.cabal: Internal compiler library
+ libraries/ghc-compact/ghc-compact.cabal: Core library
+ libraries/ghc-heap/ghc-heap.cabal: GHC heap-walking library
+ libraries/ghc-prim/ghc-prim.cabal: Core library
+ utils/haddock/haddock-api/haddock-api.cabal: Dependency of ``haddock`` executable
+ utils/haddock/haddock-library/haddock-library.cabal: Dependency of ``haddock`` executable
+ libraries/haskeline/haskeline.cabal: Dependency of ``ghci`` executable
+ libraries/hpc/hpc.cabal: Dependency of ``hpc`` executable
+ libraries/integer-gmp/integer-gmp.cabal: Core library
+ libraries/mtl/mtl.cabal: Dependency of ``Cabal`` library
+ libraries/parsec/parsec.cabal: Dependency of ``Cabal`` library
+ libraries/pretty/pretty.cabal: Dependency of ``ghc`` library
+ libraries/process/process.cabal: Dependency of ``ghc`` library
+ libraries/stm/stm.cabal: Dependency of ``haskeline`` library
+ libraries/template-haskell/template-haskell.cabal: Core library
+ libraries/terminfo/terminfo.cabal: Dependency of ``haskeline`` library
+ libraries/text/text.cabal: Dependency of ``Cabal`` library
+ libraries/time/time.cabal: Dependency of ``ghc`` library
+ libraries/transformers/transformers.cabal: Dependency of ``ghc`` library
+ libraries/unix/unix.cabal: Dependency of ``ghc`` library
+ libraries/Win32/Win32.cabal: Dependency of ``ghc`` library
+ libraries/xhtml/xhtml.cabal: Dependency of ``haddock`` executable
+ libraries/os-string/os-string.cabal: Dependency of ``filepath`` library
+ libraries/file-io/file-io.cabal: Dependency of ``directory`` library
=====================================
docs/users_guide/release-notes.rst
=====================================
@@ -4,4 +4,4 @@ Release notes
.. toctree::
:maxdepth: 1
- 9.14.1-notes
+ 9.16.1-notes
=====================================
testsuite/tests/hpc/recsel/recsel.hs
=====================================
@@ -10,7 +10,8 @@ import Trace.Hpc.Tix
import Trace.Hpc.Reflect
data Foo = Foo { fooA, fooB, fooC, fooD, fooE, fooF, fooG, fooH, fooI
- , fooJ, fooK, fooL, fooM, fooN, fooO :: Int }
+ , fooJ, fooK, fooL, fooM, fooN, fooO :: Int
+ , fooP, fooQ :: Maybe Int }
data Bar = Bar { barFoo :: Foo }
fAB Foo{..} = fooA + fooB
@@ -35,14 +36,17 @@ fL = runIdentity . runKleisli (proc f -> do
fM f | Foo{..} <- f = fooM
fN f = fooN f
fO = runIdentity . runKleisli (proc Foo{..} -> returnA -< fooO)
+fP Foo{fooP = Just x} = x
+fP _ = 0
+fQ Foo{fooQ = Just 42} = 1
recSel (n, TopLevelBox [s]) | any (`isPrefixOf` s) ["foo", "bar"] = Just (n, s)
recSel _ = Nothing
main = do
- let foo = Foo 42 23 0 1 2 3 4 5 6 7 0xaffe 9 10 11 12
+ let foo = Foo 42 23 0 1 2 3 4 5 6 7 0xaffe 9 10 11 12 (Just 13) (Just 42)
mapM_ (print . ($ foo))
- [fAB, fC, fD False, fE . Bar, fF, fG, fH, fI, fJ, fK, fL, fM, fN, fO]
+ [fAB, fC, fD False, fE . Bar, fF, fG, fH, fI, fJ, fK, fL, fM, fN, fO, fP, fQ]
(Mix _ _ _ _ mixs) <- readMix [".hpc"] (Left "Main")
let sels = mapMaybe recSel . zip [0..] $ map snd mixs
(Tix [TixModule "Main" _ _ tix]) <- examineTix
=====================================
testsuite/tests/hpc/recsel/recsel.stdout
=====================================
@@ -12,13 +12,15 @@
10
11
12
-(0,"barFoo")
+13
+1
+(1,"barFoo")
(1,"fooA")
(1,"fooB")
(1,"fooC")
(0,"fooD")
(1,"fooE")
-(0,"fooF")
+(1,"fooF")
(1,"fooG")
(1,"fooH")
(1,"fooI")
@@ -28,3 +30,5 @@
(1,"fooM")
(1,"fooN")
(1,"fooO")
+(1,"fooP")
+(0,"fooQ")
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0434af813cd5aa629ef7566cd267d7…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/0434af813cd5aa629ef7566cd267d7…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
Apoorv Ingle pushed to branch wip/spj-apporv-Oct24 at Glasgow Haskell Compiler / GHC
Commits:
afc3d72a by Apoorv Ingle at 2025-08-13T16:49:02-05:00
This commit:
- Streamlines implementations of `tcExpr` and `tcXExpr` to work on `XExpr`
Calls `setInGeneratedCode` everytime the typechecker goes over an `XExpr`
- Kills `VACtxt` (and its associated VAExpansion and VACall) datatype, it is subsumed by simply a SrcSpan.
- Kills the function `addHeadCtxt` as it is now mearly setting a location
- The function `tcValArgs` does its own argument number management
- Makes `splitHsApps` not look through `XExpr`
- `tcExprSigma` is called if the head of the expression after calling `splitHsApps` turns out to be an `XExpr`
- Removes location information from `OrigPat` payload
- Removes special case of tcBody from `tcLambdaMatches`
- Removes special case of `dsExpr` for `ExpandedThingTc`
- Moves `setQLInstLevel` inside `tcInstFun`
- Rename `HsThingRn` to `SrcCodeCtxt`
- Kills `tcl_in_gen_code` and `tcl_err_ctxt`. It is subsumed by `ErrCtxtStack`
- Kills `ExpectedFunTyOrig`. It is subsumed by `CtOrigin`
- Fixes `CtOrigin` for `HsProjection` case in `exprCtOrigin`. It was previously assigned to be `SectionOrigin`. It is now just the expression
- Adds a new `CtOrigin.ExpansionOrigin` for storing the original syntax
- Adds a new `CtOrigin.ExpectedTySyntax` as a replacement for `ExpectedTySyntaxOp`. Cannot kill the former yet because of `ApplicativeDo`
- Renames `tcMonoExpr` -> `tcMonoLExpr`, `tcMonoExprNC` -> `tcMonoLExpr`
- Renames `EValArg`, `EValArgQL` fields: `ea_ctxt` -> `ea_loc_span` and `eaql_ctx` -> `eaql_loc_span`
Notes added [Error Context Stack]
Notes updated Note [Expanding HsDo with XXExprGhcRn]
-------------------------
Metric Decrease:
T9020
-------------------------
- - - - -
53 changed files:
- compiler/GHC/Hs.hs
- compiler/GHC/Hs/Expr.hs
- compiler/GHC/Hs/Instances.hs
- compiler/GHC/HsToCore/Expr.hs
- compiler/GHC/HsToCore/Match.hs
- compiler/GHC/HsToCore/Pmc.hs
- compiler/GHC/HsToCore/Quote.hs
- compiler/GHC/HsToCore/Ticks.hs
- compiler/GHC/Rename/Expr.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Gen/App.hs
- + compiler/GHC/Tc/Gen/App.hs-boot
- compiler/GHC/Tc/Gen/Do.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/Expr.hs-boot
- compiler/GHC/Tc/Gen/Head.hs
- compiler/GHC/Tc/Gen/Match.hs
- compiler/GHC/Tc/Gen/Pat.hs
- compiler/GHC/Tc/Instance/Class.hs
- compiler/GHC/Tc/Types/ErrCtxt.hs
- compiler/GHC/Tc/Types/LclEnv.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Utils/Monad.hs
- compiler/GHC/Tc/Utils/Unify.hs
- testsuite/tests/default/default-fail05.stderr
- testsuite/tests/indexed-types/should_fail/T2693.stderr
- testsuite/tests/indexed-types/should_fail/T5439.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail10.stderr
- testsuite/tests/parser/should_fail/RecordDotSyntaxFail11.stderr
- testsuite/tests/plugins/test-defaulting-plugin.stderr
- testsuite/tests/polykinds/T13393.stderr
- testsuite/tests/printer/T17697.stderr
- testsuite/tests/rep-poly/RepPolyDoBind.stderr
- testsuite/tests/rep-poly/RepPolyDoBody1.stderr
- testsuite/tests/rep-poly/RepPolyDoBody2.stderr
- testsuite/tests/rep-poly/RepPolyRecordUpdate.stderr
- testsuite/tests/typecheck/should_compile/T14590.stderr
- testsuite/tests/typecheck/should_compile/valid_hole_fits.stderr
- testsuite/tests/typecheck/should_fail/DoExpansion1.stderr
- testsuite/tests/typecheck/should_fail/DoExpansion2.stderr
- testsuite/tests/typecheck/should_fail/T10971d.stderr
- testsuite/tests/typecheck/should_fail/T13311.stderr
- testsuite/tests/typecheck/should_fail/T24064.stderr
- testsuite/tests/typecheck/should_fail/T3323.stderr
- testsuite/tests/typecheck/should_fail/T3613.stderr
- testsuite/tests/typecheck/should_fail/T7851.stderr
- testsuite/tests/typecheck/should_fail/T8603.stderr
- testsuite/tests/typecheck/should_fail/T9612.stderr
- testsuite/tests/typecheck/should_fail/tcfail102.stderr
- testsuite/tests/typecheck/should_fail/tcfail128.stderr
- testsuite/tests/typecheck/should_fail/tcfail168.stderr
- testsuite/tests/warnings/should_fail/CaretDiagnostics1.stderr
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/afc3d72acc8fa4b402e811b43a7bea4…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/afc3d72acc8fa4b402e811b43a7bea4…
You're receiving this email because of your account on gitlab.haskell.org.
1
0

13 Aug '25
Luite Stegeman pushed to branch wip/ubxsumtag at Glasgow Haskell Compiler / GHC
Commits:
77d94fb3 by Luite Stegeman at 2025-08-13T23:32:14+02:00
Support larger unboxed sums
- - - - -
1 changed file:
- compiler/GHC/Builtin/Uniques.hs
Changes:
=====================================
compiler/GHC/Builtin/Uniques.hs
=====================================
@@ -97,37 +97,37 @@ Note [Unique layout for unboxed sums]
Sum arities start from 2. The encoding is a bit funny: we break up the
integral part into bitfields for the arity, an alternative index (which is
-taken to be 0xfc in the case of the TyCon), and, in the case of a datacon, a
-tag (used to identify the sum's TypeRep binding).
+taken to be 0x1ffc in the case of the TyCon), and, in the case of a datacon,
+a tag (used to identify the sum's TypeRep binding).
This layout is chosen to remain compatible with the usual unique allocation
for wired-in data constructors described in GHC.Types.Unique
TyCon for sum of arity k:
- 00000000 kkkkkkkk 11111100
+ kkkkkkkk kkk11111 11111100
TypeRep of TyCon for sum of arity k:
- 00000000 kkkkkkkk 11111101
+ kkkkkkkk kkk11111 11111101
DataCon for sum of arity k and alternative n (zero-based):
- 00000000 kkkkkkkk nnnnnn00
+ kkkkkkkk kkknnnnn nnnnnn00
TypeRep for sum DataCon of arity k and alternative n (zero-based):
- 00000000 kkkkkkkk nnnnnn10
+ kkkkkkkk kkknnnnn nnnnnn10
-}
mkSumTyConUnique :: Arity -> Unique
mkSumTyConUnique arity =
- assertPpr (arity <= 0x3f) (ppr arity) $
- -- 0x3f since we only have 6 bits to encode the
+ assertPpr (arity <= 0x7ff) (ppr arity) $
+ -- 0x7ff since we only have 11 bits to encode the
-- alternative
- mkUniqueInt 'z' (arity `shiftL` 8 .|. 0xfc)
+ mkUniqueInt 'z' (arity `shiftL` 13 .|. 0x1ffc)
-- | Inverse of 'mkSumTyConUnique'
isSumTyConUnique :: Unique -> Maybe Arity
isSumTyConUnique u =
- case (tag, n .&. 0xfc) of
- ('z', 0xfc) -> Just (word64ToInt n `shiftR` 8)
+ case (tag, n .&. 0x1ffc) of
+ ('z', 0x1ffc) -> Just (word64ToInt n `shiftR` 13)
_ -> Nothing
where
(tag, n) = unpkUnique u
@@ -137,11 +137,11 @@ mkSumDataConUnique alt arity
| alt >= arity
= panic ("mkSumDataConUnique: " ++ show alt ++ " >= " ++ show arity)
| otherwise
- = mkUniqueInt 'z' (arity `shiftL` 8 + alt `shiftL` 2) {- skip the tycon -}
+ = mkUniqueInt 'z' (arity `shiftL` 13 + alt `shiftL` 2) {- skip the tycon -}
getUnboxedSumName :: Int -> Name
getUnboxedSumName n
- | n .&. 0xfc == 0xfc
+ | n .&. 0x1ffc == 0x1ffc
= case tag of
0x0 -> tyConName $ sumTyCon arity
0x1 -> getRep $ sumTyCon arity
@@ -155,8 +155,8 @@ getUnboxedSumName n
| otherwise
= pprPanic "getUnboxedSumName" (ppr n)
where
- arity = n `shiftR` 8
- alt = (n .&. 0xfc) `shiftR` 2
+ arity = n `shiftR` 13
+ alt = (n .&. 0x1ffc) `shiftR` 2
tag = 0x3 .&. n
getRep tycon =
fromMaybe (pprPanic "getUnboxedSumName(getRep)" (ppr tycon))
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/77d94fb362bf155f2589f5df2a063b5…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/77d94fb362bf155f2589f5df2a063b5…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
Cheng Shao pushed new branch wip/js-no-llvm at Glasgow Haskell Compiler / GHC
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/js-no-llvm
You're receiving this email because of your account on gitlab.haskell.org.
1
0

[Git][ghc/ghc][wip/warning-for-last-and-init] 2 commits: Revert GHC.Core.Utils
by Bodigrim (@Bodigrim) 13 Aug '25
by Bodigrim (@Bodigrim) 13 Aug '25
13 Aug '25
Bodigrim pushed to branch wip/warning-for-last-and-init at Glasgow Haskell Compiler / GHC
Commits:
fbaf30f7 by Andrew Lelechenko at 2025-08-13T19:10:30+01:00
Revert GHC.Core.Utils
- - - - -
3fa7314c by Andrew Lelechenko at 2025-08-13T19:11:42+01:00
Revert template-haskell
- - - - -
3 changed files:
- compiler/GHC/Core/Utils.hs
- libraries/template-haskell/vendored-filepath/System/FilePath/Posix.hs
- libraries/template-haskell/vendored-filepath/System/FilePath/Windows.hs
Changes:
=====================================
compiler/GHC/Core/Utils.hs
=====================================
@@ -7,6 +7,9 @@ Utility functions on @Core@ syntax
-}
-- | Commonly useful utilities for manipulating the Core language
+
+{-# OPTIONS_GHC -Wno-x-partial #-}
+
module GHC.Core.Utils (
-- * Constructing expressions
mkCast, mkCastMCo, mkPiMCo,
@@ -112,7 +115,8 @@ import GHC.Utils.Misc
import Data.ByteString ( ByteString )
import Data.Function ( on )
-import Data.List ( sort, sortBy, partition, zipWith4, mapAccumL, unsnoc )
+import Data.List ( sort, sortBy, partition, zipWith4, mapAccumL )
+import qualified Data.List as Partial ( init, last )
import Data.Ord ( comparing )
import Control.Monad ( guard )
import qualified Data.Set as Set
@@ -1870,10 +1874,10 @@ app_ok fun_ok primop_ok fun args
PrimOpId op _
| primOpIsDiv op
- , Just (initArgs, Lit divisor) <- unsnoc args
+ , Lit divisor <- Partial.last args
-- there can be 2 args (most div primops) or 3 args
-- (WordQuotRem2Op), hence the use of last/init
- -> not (isZeroLit divisor) && all (expr_ok fun_ok primop_ok) initArgs
+ -> not (isZeroLit divisor) && all (expr_ok fun_ok primop_ok) (Partial.init args)
-- Special case for dividing operations that fail
-- In general they are NOT ok-for-speculation
-- (which primop_ok will catch), but they ARE OK
=====================================
libraries/template-haskell/vendored-filepath/System/FilePath/Posix.hs
=====================================
@@ -1,6 +1,7 @@
-- Vendored from filepath v1.4.2.2
{-# LANGUAGE PatternGuards #-}
+{-# OPTIONS_GHC -Wno-x-partial #-}
-- This template expects CPP definitions for:
-- MODULE_NAME = Posix | Windows
@@ -104,7 +105,7 @@ module System.FilePath.Posix
import Data.Char(toLower, toUpper, isAsciiLower, isAsciiUpper)
import Data.Maybe(isJust)
-import Data.List(stripPrefix, isSuffixOf, uncons, unsnoc)
+import Data.List(stripPrefix, isSuffixOf)
import System.Environment(getEnv)
@@ -203,20 +204,14 @@ isExtSeparator = (== extSeparator)
splitSearchPath :: String -> [FilePath]
splitSearchPath = f
where
- f xs = let (pre, post) = break isSearchPathSeparator xs
- in case uncons post of
- Nothing -> g pre
- Just (_, t) -> g pre ++ f t
-
- g x = case uncons x of
- Nothing -> ["." | isPosix]
- Just (h, t)
- | h == '"'
- , Just{} <- uncons t -- >= 2
- , isWindows
- , Just (i, l) <- unsnoc t
- , l == '"' -> [i]
- | otherwise -> [x]
+ f xs = case break isSearchPathSeparator xs of
+ (pre, [] ) -> g pre
+ (pre, _:post) -> g pre ++ f post
+
+ g "" = ["." | isPosix]
+ g ('\"':x@(_:_)) | isWindows && last x == '\"' = [init x]
+ g x = [x]
+
-- | Get a list of 'FilePath's in the $PATH variable.
getSearchPath :: IO [FilePath]
@@ -239,17 +234,12 @@ getSearchPath = fmap splitSearchPath (getEnv "PATH")
-- > splitExtension "file/path.txt.bob.fred" == ("file/path.txt.bob",".fred")
-- > splitExtension "file/path.txt/" == ("file/path.txt/","")
splitExtension :: FilePath -> (String, String)
-splitExtension x = case unsnoc nameDot of
- -- Imagine x = "no-dots", then nameDot = ""
- Nothing -> (x, mempty)
- Just (initNameDot, _)
- -- Imagine x = "\\shared.with.dots\no-dots"
- | isWindows && null (dropDrive nameDot) -> (x, mempty)
- -- Imagine x = "dir.with.dots/no-dots"
- | any isPathSeparator ext -> (x, mempty)
- | otherwise -> (initNameDot, extSeparator : ext)
- where
- (nameDot, ext) = breakEnd isExtSeparator x
+splitExtension x = case nameDot of
+ "" -> (x,"")
+ _ -> (dir ++ init nameDot, extSeparator : ext)
+ where
+ (dir,file) = splitFileName_ x
+ (nameDot,ext) = breakEnd isExtSeparator file
-- | Get the extension of a file, returns @\"\"@ for no extension, @.ext@ otherwise.
--
@@ -605,13 +595,9 @@ replaceBaseName pth nam = combineAlways a (nam <.> ext)
-- > hasTrailingPathSeparator "test" == False
-- > hasTrailingPathSeparator "test/" == True
hasTrailingPathSeparator :: FilePath -> Bool
-hasTrailingPathSeparator = isJust . getTrailingPathSeparator
+hasTrailingPathSeparator "" = False
+hasTrailingPathSeparator x = isPathSeparator (last x)
-getTrailingPathSeparator :: FilePath -> Maybe Char
-getTrailingPathSeparator x = case unsnoc x of
- Just (_, lastX)
- | isPathSeparator lastX -> Just lastX
- _ -> Nothing
hasLeadingPathSeparator :: FilePath -> Bool
hasLeadingPathSeparator "" = False
@@ -634,12 +620,12 @@ addTrailingPathSeparator x = if hasTrailingPathSeparator x then x else x ++ [pat
-- > Windows: dropTrailingPathSeparator "\\" == "\\"
-- > Posix: not (hasTrailingPathSeparator (dropTrailingPathSeparator x)) || isDrive x
dropTrailingPathSeparator :: FilePath -> FilePath
-dropTrailingPathSeparator x = case getTrailingPathSeparator x of
- Just lastX
- | not (isDrive x)
- -> let x' = dropWhileEnd isPathSeparator x
- in if null x' then [lastX] else x'
- _ -> x
+dropTrailingPathSeparator x =
+ if hasTrailingPathSeparator x && not (isDrive x)
+ then let x' = dropWhileEnd isPathSeparator x
+ in if null x' then [last x] else x'
+ else x
+
-- | Get the directory name, move up one level.
--
@@ -878,37 +864,28 @@ makeRelative root path
-- > Posix: normalise "bob/fred/." == "bob/fred/"
-- > Posix: normalise "//home" == "/home"
normalise :: FilePath -> FilePath
-normalise filepath =
- result <>
- (if addPathSeparator
- then [pathSeparator]
- else mempty)
- where
- (drv,pth) = splitDrive filepath
-
- result = joinDrive' (normaliseDrive drv) (f pth)
+normalise path = result ++ [pathSeparator | addPathSeparator]
+ where
+ (drv,pth) = splitDrive path
+ result = joinDrive' (normaliseDrive drv) (f pth)
- joinDrive' d p
- = if null d && null p
- then "."
- else joinDrive d p
+ joinDrive' "" "" = "."
+ joinDrive' d p = joinDrive d p
- addPathSeparator = isDirPath pth
- && not (hasTrailingPathSeparator result)
- && not (isRelativeDrive drv)
+ addPathSeparator = isDirPath pth
+ && not (hasTrailingPathSeparator result)
+ && not (isRelativeDrive drv)
- isDirPath xs = hasTrailingPathSeparator xs || case unsnoc xs of
- Nothing -> False
- Just (initXs, lastXs) -> lastXs == '.' && hasTrailingPathSeparator initXs
+ isDirPath xs = hasTrailingPathSeparator xs
+ || not (null xs) && last xs == '.' && hasTrailingPathSeparator (init xs)
- f = joinPath . dropDots . propSep . splitDirectories
+ f = joinPath . dropDots . propSep . splitDirectories
- propSep (x:xs)
- | all isPathSeparator x = [pathSeparator] : xs
- | otherwise = x : xs
- propSep [] = []
+ propSep (x:xs) | all isPathSeparator x = [pathSeparator] : xs
+ | otherwise = x : xs
+ propSep [] = []
- dropDots = filter ("." /=)
+ dropDots = filter ("." /=)
normaliseDrive :: FilePath -> FilePath
normaliseDrive "" = ""
=====================================
libraries/template-haskell/vendored-filepath/System/FilePath/Windows.hs
=====================================
@@ -1,6 +1,7 @@
-- Vendored from filepath v1.4.2.2
{-# LANGUAGE PatternGuards #-}
+{-# OPTIONS_GHC -Wno-x-partial #-}
-- This template expects CPP definitions for:
-- MODULE_NAME = Posix | Windows
@@ -104,7 +105,7 @@ module System.FilePath.Windows
import Data.Char(toLower, toUpper, isAsciiLower, isAsciiUpper)
import Data.Maybe(isJust)
-import Data.List(stripPrefix, isSuffixOf, uncons, unsnoc)
+import Data.List(stripPrefix, isSuffixOf)
import System.Environment(getEnv)
@@ -203,20 +204,14 @@ isExtSeparator = (== extSeparator)
splitSearchPath :: String -> [FilePath]
splitSearchPath = f
where
- f xs = let (pre, post) = break isSearchPathSeparator xs
- in case uncons post of
- Nothing -> g pre
- Just (_, t) -> g pre ++ f t
-
- g x = case uncons x of
- Nothing -> ["." | isPosix]
- Just (h, t)
- | h == '"'
- , Just{} <- uncons t -- >= 2
- , isWindows
- , Just (i, l) <- unsnoc t
- , l == '"' -> [i]
- | otherwise -> [x]
+ f xs = case break isSearchPathSeparator xs of
+ (pre, [] ) -> g pre
+ (pre, _:post) -> g pre ++ f post
+
+ g "" = ["." | isPosix]
+ g ('\"':x@(_:_)) | isWindows && last x == '\"' = [init x]
+ g x = [x]
+
-- | Get a list of 'FilePath's in the $PATH variable.
getSearchPath :: IO [FilePath]
@@ -239,17 +234,12 @@ getSearchPath = fmap splitSearchPath (getEnv "PATH")
-- > splitExtension "file/path.txt.bob.fred" == ("file/path.txt.bob",".fred")
-- > splitExtension "file/path.txt/" == ("file/path.txt/","")
splitExtension :: FilePath -> (String, String)
-splitExtension x = case unsnoc nameDot of
- -- Imagine x = "no-dots", then nameDot = ""
- Nothing -> (x, mempty)
- Just (initNameDot, _)
- -- Imagine x = "\\shared.with.dots\no-dots"
- | isWindows && null (dropDrive nameDot) -> (x, mempty)
- -- Imagine x = "dir.with.dots/no-dots"
- | any isPathSeparator ext -> (x, mempty)
- | otherwise -> (initNameDot, extSeparator : ext)
- where
- (nameDot, ext) = breakEnd isExtSeparator x
+splitExtension x = case nameDot of
+ "" -> (x,"")
+ _ -> (dir ++ init nameDot, extSeparator : ext)
+ where
+ (dir,file) = splitFileName_ x
+ (nameDot,ext) = breakEnd isExtSeparator file
-- | Get the extension of a file, returns @\"\"@ for no extension, @.ext@ otherwise.
--
@@ -605,13 +595,9 @@ replaceBaseName pth nam = combineAlways a (nam <.> ext)
-- > hasTrailingPathSeparator "test" == False
-- > hasTrailingPathSeparator "test/" == True
hasTrailingPathSeparator :: FilePath -> Bool
-hasTrailingPathSeparator = isJust . getTrailingPathSeparator
+hasTrailingPathSeparator "" = False
+hasTrailingPathSeparator x = isPathSeparator (last x)
-getTrailingPathSeparator :: FilePath -> Maybe Char
-getTrailingPathSeparator x = case unsnoc x of
- Just (_, lastX)
- | isPathSeparator lastX -> Just lastX
- _ -> Nothing
hasLeadingPathSeparator :: FilePath -> Bool
hasLeadingPathSeparator "" = False
@@ -634,12 +620,12 @@ addTrailingPathSeparator x = if hasTrailingPathSeparator x then x else x ++ [pat
-- > Windows: dropTrailingPathSeparator "\\" == "\\"
-- > Posix: not (hasTrailingPathSeparator (dropTrailingPathSeparator x)) || isDrive x
dropTrailingPathSeparator :: FilePath -> FilePath
-dropTrailingPathSeparator x = case getTrailingPathSeparator x of
- Just lastX
- | not (isDrive x)
- -> let x' = dropWhileEnd isPathSeparator x
- in if null x' then [lastX] else x'
- _ -> x
+dropTrailingPathSeparator x =
+ if hasTrailingPathSeparator x && not (isDrive x)
+ then let x' = dropWhileEnd isPathSeparator x
+ in if null x' then [last x] else x'
+ else x
+
-- | Get the directory name, move up one level.
--
@@ -878,37 +864,28 @@ makeRelative root path
-- > Posix: normalise "bob/fred/." == "bob/fred/"
-- > Posix: normalise "//home" == "/home"
normalise :: FilePath -> FilePath
-normalise filepath =
- result <>
- (if addPathSeparator
- then [pathSeparator]
- else mempty)
- where
- (drv,pth) = splitDrive filepath
-
- result = joinDrive' (normaliseDrive drv) (f pth)
+normalise path = result ++ [pathSeparator | addPathSeparator]
+ where
+ (drv,pth) = splitDrive path
+ result = joinDrive' (normaliseDrive drv) (f pth)
- joinDrive' d p
- = if null d && null p
- then "."
- else joinDrive d p
+ joinDrive' "" "" = "."
+ joinDrive' d p = joinDrive d p
- addPathSeparator = isDirPath pth
- && not (hasTrailingPathSeparator result)
- && not (isRelativeDrive drv)
+ addPathSeparator = isDirPath pth
+ && not (hasTrailingPathSeparator result)
+ && not (isRelativeDrive drv)
- isDirPath xs = hasTrailingPathSeparator xs || case unsnoc xs of
- Nothing -> False
- Just (initXs, lastXs) -> lastXs == '.' && hasTrailingPathSeparator initXs
+ isDirPath xs = hasTrailingPathSeparator xs
+ || not (null xs) && last xs == '.' && hasTrailingPathSeparator (init xs)
- f = joinPath . dropDots . propSep . splitDirectories
+ f = joinPath . dropDots . propSep . splitDirectories
- propSep (x:xs)
- | all isPathSeparator x = [pathSeparator] : xs
- | otherwise = x : xs
- propSep [] = []
+ propSep (x:xs) | all isPathSeparator x = [pathSeparator] : xs
+ | otherwise = x : xs
+ propSep [] = []
- dropDots = filter ("." /=)
+ dropDots = filter ("." /=)
normaliseDrive :: FilePath -> FilePath
normaliseDrive "" = ""
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/846063f4ef658afb435626b8966f3d…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/846063f4ef658afb435626b8966f3d…
You're receiving this email because of your account on gitlab.haskell.org.
1
0

[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 15 commits: Extend record-selector usage ticking to all binds using a record field
by Marge Bot (@marge-bot) 13 Aug '25
by Marge Bot (@marge-bot) 13 Aug '25
13 Aug '25
Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC
Commits:
4e8e51d4 by Florian Ragwitz at 2025-08-13T14:00:15-04:00
Extend record-selector usage ticking to all binds using a record field
This extends the previous handling of ticking for RecordWildCards and
NamedFieldPuns to all var bindings that involve record selectors.
Note that certain patterns such as `Foo{foo = 42}` will currently not tick the
`foo` selector, as ticking is triggered by `HsVar`s.
Closes #26191.
- - - - -
a3fecbbc by Florian Ragwitz at 2025-08-13T14:00:15-04:00
Add release notes for 9.16.1 and move description of latest HPC changes there.
- - - - -
edb9714c by Ben Gamari at 2025-08-13T14:00:17-04:00
rts: Clarify rationale for undefined atomic wrappers
Since c06e3f46d24ef69f3a3d794f5f604cb8c2a40cbc the RTS has declared
various atomic operation wrappers defined by ghc-internal as undefined.
While the rationale for this isn't clear from the commit message, I
believe that this is necessary due to the unregisterised backend.
Specifically, the code generator will reference these symbols when
compiling RTS Cmm sources.
- - - - -
5ed6f6ed by Andreas Klebinger at 2025-08-13T14:00:19-04:00
Make unexpected LLVM versions a warning rather than an error.
Typically a newer LLVM version *will* work so erroring out if
a user uses a newer LLVM version is too aggressive.
Fixes #25915
- - - - -
2c914efc by fendor at 2025-08-13T14:00:20-04:00
Store `StackTrace` and `StackSnapshot` in `Backtraces`
Instead of decoding the stack traces when collecting the `Backtraces`,
defer this decoding until actually showing the `Backtraces`.
This allows users to customise how `Backtraces` are displayed by
using a custom implementation of `displayExceptionWithInfo`, overwriting
the default implementation for `Backtraces` (`displayBacktraces`).
- - - - -
3ac3d46a by fendor at 2025-08-13T14:00:20-04:00
Allow users to customise the collection of exception annotations
Add a global `CollectExceptionAnnotationMechanism` which determines how
`ExceptionAnnotation`s are collected upon throwing an `Exception`.
This API is exposed via `ghc-experimental`.
By overriding how we collect `Backtraces`, we can control how the
`Backtraces` are displayed to the user by newtyping `Backtraces` and
giving a different instance for `ExceptionAnnotation`.
A concrete use-case for this feature is allowing us to experiment with
alternative stack decoders, without having to modify `base`, which take
additional information from the stack frames.
This commit does not modify how `Backtraces` are currently
collected or displayed.
- - - - -
d7f206e7 by fendor at 2025-08-13T14:00:20-04:00
Expose Backtraces internals from ghc-experimental
Additionally, expose the same API `base:Control.Exception.Backtrace`
to make it easier to use as a drop-in replacement.
- - - - -
c315a44f by Reed Mullanix at 2025-08-13T14:00:25-04:00
ghc-internal: Fix naturalAndNot for NB/NS case
When the first argument to `naturalAndNot` is larger than a `Word` and the second is `Word`-sized, `naturalAndNot` will truncate the
result:
```
>>> naturalAndNot ((2 ^ 65) .|. (2 ^ 3)) (2 ^ 3)
0
```
In contrast, `naturalAndNot` does not truncate when both arguments are larger than a `Word`, so this appears to be a bug.
Luckily, the fix is pretty easy: we just need to call `bigNatAndNotWord#` instead of truncating.
Fixes #26230
- - - - -
760a0c6c by Simon Hengel at 2025-08-13T14:00:27-04:00
Report -pgms as a deprecated flag
(instead of reporting an unspecific warning)
Before:
on the commandline: warning:
Object splitting was removed in GHC 8.8
After:
on the commandline: warning: [GHC-53692] [-Wdeprecated-flags]
-pgms is deprecated: Object splitting was removed in GHC 8.8
- - - - -
f4db8c4a by Zubin Duggal at 2025-08-13T14:00:28-04:00
testsuite: Be more permissive when filtering out GNU_PROPERTY_TYPE linker warnings
The warning text is slightly different with ld.bfd.
Fixes #26249
- - - - -
3afb4cc6 by Simon Hengel at 2025-08-13T14:00:29-04:00
Refactoring: Don't misuse `MCDiagnostic` for lint messages
`MCDiagnostic` is meant to be used for compiler diagnostics.
Any code that creates `MCDiagnostic` directly, without going through
`GHC.Driver.Errors.printMessage`, side steps `-fdiagnostics-as-json`
(see e.g. !14475, !14492 !14548).
To avoid this in the future I want to control more narrowly who creates
`MCDiagnostic` (see #24113).
Some parts of the compiler use `MCDiagnostic` purely for formatting
purposes, without creating any real compiler diagnostics. This change
introduces a helper function, `formatDiagnostic`, that can be used in
such cases instead of constructing `MCDiagnostic`.
- - - - -
d1a04ccd by Teo Camarasu at 2025-08-13T14:00:30-04:00
rts: ensure MessageBlackHole.link is always a valid closure
We turn a MessageBlackHole into an StgInd in wakeBlockingQueue().
Therefore it's important that the link field, which becomes the
indirection field, always points to a valid closure.
It's unclear whether it's currently possible for the previous behaviour
to lead to a crash, but it's good to be consistent about this invariant nonetheless.
Co-authored-by: Andreas Klebinger <klebinger.andreas(a)gmx.at>
- - - - -
f1d45b22 by Teo Camarasu at 2025-08-13T14:00:30-04:00
rts: spin if we see a WHITEHOLE in messageBlackHole
When a BLACKHOLE gets cancelled in raiseAsync, we indirect to a THUNK.
GC can then shortcut this, replacing our BLACKHOLE with a fresh THUNK.
This THUNK is not guaranteed to have a valid indirectee field.
If at the same time, a message intended for the previous BLACKHOLE is
processed and concurrently we BLACKHOLE the THUNK, thus temporarily
turning it into a WHITEHOLE, we can get a segfault, since we look at the
undefined indirectee field of the THUNK
The fix is simple: spin if we see a WHITEHOLE, and it will soon be
replaced with a valid BLACKHOLE.
Resolves #26205
- - - - -
4f9fef78 by Oleg Grenrus at 2025-08-13T14:00:31-04:00
Allow defining HasField instances for naughty fields
Resolves #26295
... as HasField solver doesn't solve for fields with "naughty"
selectors, we could as well allow defining HasField instances for these
fields.
- - - - -
e77a8e01 by Sylvain Henry at 2025-08-13T14:01:00-04:00
Fix Data.List unqualified import warning
- - - - -
61 changed files:
- compiler/GHC/Core/Lint.hs
- compiler/GHC/Driver/Errors/Ppr.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/HsToCore/Ticks.hs
- compiler/GHC/Runtime/Debugger/Breakpoints.hs
- compiler/GHC/Stg/Lint.hs
- compiler/GHC/Tc/Validity.hs
- compiler/GHC/Types/Error.hs
- compiler/GHC/Utils/Error.hs
- − docs/users_guide/9.14.1-notes.rst
- + docs/users_guide/9.16.1-notes.rst
- docs/users_guide/release-notes.rst
- libraries/base/changelog.md
- libraries/ghc-bignum/changelog.md
- + libraries/ghc-experimental/src/GHC/Exception/Backtrace/Experimental.hs
- libraries/ghc-internal/src/GHC/Internal/Bignum/Natural.hs
- libraries/ghc-internal/src/GHC/Internal/Exception.hs
- libraries/ghc-internal/src/GHC/Internal/Exception/Backtrace.hs
- libraries/ghc-internal/src/GHC/Internal/Exception/Backtrace.hs-boot
- + libraries/ghc-internal/tests/Makefile
- + libraries/ghc-internal/tests/all.T
- + libraries/ghc-internal/tests/backtraces/Makefile
- + libraries/ghc-internal/tests/backtraces/T14532a.hs
- + libraries/ghc-internal/tests/backtraces/T14532a.stdout
- + libraries/ghc-internal/tests/backtraces/T14532b.hs
- + libraries/ghc-internal/tests/backtraces/T14532b.stdout
- + libraries/ghc-internal/tests/backtraces/all.T
- rts/Messages.c
- rts/StgMiscClosures.cmm
- rts/Updates.h
- rts/external-symbols.list.in
- rts/rts.cabal
- testsuite/driver/testlib.py
- testsuite/tests/arrows/should_compile/T21301.stderr
- testsuite/tests/deSugar/should_fail/DsStrictFail.stderr
- testsuite/tests/deSugar/should_run/T20024.stderr
- testsuite/tests/deSugar/should_run/dsrun005.stderr
- testsuite/tests/deSugar/should_run/dsrun007.stderr
- testsuite/tests/deSugar/should_run/dsrun008.stderr
- testsuite/tests/deriving/should_run/T9576.stderr
- testsuite/tests/ghci/scripts/Defer02.stderr
- testsuite/tests/ghci/scripts/T15325.stderr
- testsuite/tests/hpc/recsel/recsel.hs
- testsuite/tests/hpc/recsel/recsel.stdout
- + testsuite/tests/numeric/should_run/T26230.hs
- + testsuite/tests/numeric/should_run/T26230.stdout
- testsuite/tests/numeric/should_run/all.T
- + testsuite/tests/overloadedrecflds/should_run/T26295.hs
- + testsuite/tests/overloadedrecflds/should_run/T26295.stdout
- testsuite/tests/overloadedrecflds/should_run/all.T
- testsuite/tests/patsyn/should_run/ghci.stderr
- testsuite/tests/quotes/LiftErrMsgDefer.stderr
- testsuite/tests/safeHaskell/safeLanguage/SafeLang15.stderr
- testsuite/tests/type-data/should_run/T22332a.stderr
- testsuite/tests/typecheck/should_run/T10284.stderr
- testsuite/tests/typecheck/should_run/T13838.stderr
- testsuite/tests/typecheck/should_run/T9497a-run.stderr
- testsuite/tests/typecheck/should_run/T9497b-run.stderr
- testsuite/tests/typecheck/should_run/T9497c-run.stderr
- testsuite/tests/unsatisfiable/T23816.stderr
- testsuite/tests/unsatisfiable/UnsatDefer.stderr
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f92c69fa24d6ee4a37b60966af3f25…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f92c69fa24d6ee4a37b60966af3f25…
You're receiving this email because of your account on gitlab.haskell.org.
1
0

13 Aug '25
Luite Stegeman pushed to branch wip/ubxsumtag at Glasgow Haskell Compiler / GHC
Commits:
0b20ae55 by Luite Stegeman at 2025-08-13T19:06:18+02:00
Support larger unboxed sums
- - - - -
1 changed file:
- compiler/GHC/Builtin/Uniques.hs
Changes:
=====================================
compiler/GHC/Builtin/Uniques.hs
=====================================
@@ -104,30 +104,30 @@ This layout is chosen to remain compatible with the usual unique allocation
for wired-in data constructors described in GHC.Types.Unique
TyCon for sum of arity k:
- 00000000 kkkkkkkk 11111100
+ 00kkkkkk kkkkkkkk 11111111 11111100
TypeRep of TyCon for sum of arity k:
- 00000000 kkkkkkkk 11111101
+ 00kkkkkk kkkkkkkk 11111111 11111101
DataCon for sum of arity k and alternative n (zero-based):
- 00000000 kkkkkkkk nnnnnn00
+ 00kkkkkk kkkkkkkk nnnnnnnn nnnnnn00
TypeRep for sum DataCon of arity k and alternative n (zero-based):
- 00000000 kkkkkkkk nnnnnn10
+ 00kkkkkk kkkkkkkk nnnnnnnn nnnnnn10
-}
mkSumTyConUnique :: Arity -> Unique
mkSumTyConUnique arity =
- assertPpr (arity <= 0x3f) (ppr arity) $
- -- 0x3f since we only have 6 bits to encode the
+ assertPpr (arity <= 0x3fff) (ppr arity) $
+ -- 0x3fff since we only have 14 bits to encode the
-- alternative
- mkUniqueInt 'z' (arity `shiftL` 8 .|. 0xfc)
+ mkUniqueInt 'z' (arity `shiftL` 16 .|. 0xfffc)
-- | Inverse of 'mkSumTyConUnique'
isSumTyConUnique :: Unique -> Maybe Arity
isSumTyConUnique u =
- case (tag, n .&. 0xfc) of
- ('z', 0xfc) -> Just (word64ToInt n `shiftR` 8)
+ case (tag, n .&. 0xfffc) of
+ ('z', 0xfffc) -> Just (word64ToInt n `shiftR` 16)
_ -> Nothing
where
(tag, n) = unpkUnique u
@@ -137,11 +137,11 @@ mkSumDataConUnique alt arity
| alt >= arity
= panic ("mkSumDataConUnique: " ++ show alt ++ " >= " ++ show arity)
| otherwise
- = mkUniqueInt 'z' (arity `shiftL` 8 + alt `shiftL` 2) {- skip the tycon -}
+ = mkUniqueInt 'z' (arity `shiftL` 16 + alt `shiftL` 2) {- skip the tycon -}
getUnboxedSumName :: Int -> Name
getUnboxedSumName n
- | n .&. 0xfc == 0xfc
+ | n .&. 0xfffc == 0xfffc
= case tag of
0x0 -> tyConName $ sumTyCon arity
0x1 -> getRep $ sumTyCon arity
@@ -155,7 +155,7 @@ getUnboxedSumName n
| otherwise
= pprPanic "getUnboxedSumName" (ppr n)
where
- arity = n `shiftR` 8
+ arity = n `shiftR` 16
alt = (n .&. 0xfc) `shiftR` 2
tag = 0x3 .&. n
getRep tycon =
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0b20ae55ce712687a24984b33d66168…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0b20ae55ce712687a24984b33d66168…
You're receiving this email because of your account on gitlab.haskell.org.
1
0
Ben Gamari pushed to branch wip/T23109 at Glasgow Haskell Compiler / GHC
Commits:
34fc50c1 by Ben Gamari at 2025-08-11T13:36:25-04:00
Kill IOPort#
This type is unnecessary, having been superceded by `MVar` and a rework
of WinIO's blocking logic.
See #20947.
See https://github.com/haskell/core-libraries-committee/issues/213.
- - - - -
56b32c5a by sheaf at 2025-08-12T10:00:19-04:00
Improve deep subsumption
This commit improves the DeepSubsumption sub-typing implementation
in GHC.Tc.Utils.Unify.tc_sub_type_deep by being less eager to fall back
to unification.
For example, we now are properly able to prove the subtyping relationship
((∀ a. a->a) -> Int) -> Bool <= β[tau] Bool
for an unfilled metavariable β. In this case (with an AppTy on the right),
we used to fall back to unification. No longer: now, given that the LHS
is a FunTy and that the RHS is a deep rho type (does not need any instantiation),
we try to make the RHS into a FunTy, viz.
β := (->) γ
We can then continue using covariance & contravariance of the function
arrow, which allows us to prove the subtyping relationship, instead of
trying to unify which would cause us to error out with:
Couldn't match expected type ‘β’ with actual type ‘(->) ((∀ a. a -> a) -> Int)
See Note [FunTy vs non-FunTy case in tc_sub_type_deep] in GHC.Tc.Utils.Unify.
The other main improvement in this patch concerns type inference.
The main subsumption logic happens (before & after this patch) in
GHC.Tc.Gen.App.checkResultTy. However, before this patch, all of the
DeepSubsumption logic only kicked in in 'check' mode, not in 'infer' mode.
This patch adds deep instantiation in the 'infer' mode of checkResultTy
when we are doing deep subsumption, which allows us to accept programs
such as:
f :: Int -> (forall a. a->a)
g :: Int -> Bool -> Bool
test1 b =
case b of
True -> f
False -> g
test2 b =
case b of
True -> g
False -> f
See Note [Deeply instantiate in checkResultTy when inferring].
Finally, we add representation-polymorphism checks to ensure that the
lambda abstractions we introduce when doing subsumption obey the
representation polymorphism invariants of Note [Representation polymorphism invariants]
in GHC.Core. See Note [FunTy vs FunTy case in tc_sub_type_deep].
This is accompanied by a courtesy change to `(<.>) :: HsWrapper -> HsWrapper -> HsWrapper`,
adding the equation:
WpCast c1 <.> WpCast c2 = WpCast (c1 `mkTransCo` c2)
This is useful because mkWpFun does not introduce an eta-expansion when
both of the argument & result wrappers are casts; so this change allows
us to avoid introducing lambda abstractions when casts suffice.
Fixes #26225
- - - - -
d175aff8 by Sylvain Henry at 2025-08-12T10:01:31-04:00
Add regression test for #18619
- - - - -
a3983a26 by Sylvain Henry at 2025-08-12T10:02:20-04:00
RTS: remove some TSAN annotations (#20464)
Use RELAXED_LOAD_ALWAYS macro instead.
- - - - -
0434af81 by Ben Gamari at 2025-08-12T10:03:02-04:00
Bump time submodule to 1.15
Also required bumps of Cabal, directory, and hpc.
- - - - -
ff0c70ba by Simon Peyton Jones at 2025-08-13T13:02:07-04:00
Make injecting implicit bindings into its own pass
Previously we were injecting "impliicit bindings" (data constructor
worker and wrappers etc)
- both at the end of CoreTidy,
- and at the start of CorePrep
This is unpleasant and confusing. This patch puts it it its own pass,
addImplicitBinds, which runs between the two.
The function `GHC.CoreToStg.AddImplicitBinds.addImplicitBinds` now takes /all/
TyCons, not just the ones for algebraic data types. That change ripples
through to
- corePrepPgm
- doCodeGen
- byteCodeGen
All take [TyCon] which includes all TyCons
- - - - -
876aac38 by Simon Peyton Jones at 2025-08-13T13:02:08-04:00
Implement unary classes
The big change is described exhaustively in
Note [Unary class magic] in GHC.Core.TyCon
Other changes
* We never unbox class dictionaries in worker/wrapper. This has been true for some
time now, but the logic is now centralised in functions in
GHC.Core.Opt.WorkWrap.Utils, namely `canUnboxTyCon`, and `canUnboxArg`
See Note [Do not unbox class dictionaries] in GHC.Core.Opt.WorkWrap.Utils.
* Refactored the `notWorthFloating` logic in GHc.Core.Opt.SetLevels.
I can't remember if I actually changed any behaviour here, but if so it's
only in a corner cases.
* Fixed a bug in `GHC.Core.TyCon.isEnumerationTyCon`, which was wrongly returning
True for (##).
* Remove redundant Role argument to `liftCoSubstWithEx`. It was always
Representational.
* I refactored evidence generation in the constraint solver:
* Made GHC.Tc.Types.Evidence contain better abstactions for evidence
generation.
* I deleted the file `GHC.Tc.Types.EvTerm` and merged its (small) contents
elsewhere. It wasn't paying its way.
* Made evidence for implicit parameters go via a proper abstraction.
* Fix inlineBoringOk; see (IB6) in Note [inlineBoringOk]
This fixes a slowdown in `countdownEffectfulDynLocal`
in the `effectful` library.
Smaller things
* Rename `isDataTyCon` to `isBoxedDataTyCon`.
* GHC.Core.Corecion.liftCoSubstWithEx was only called with Representational role,
so I baked that into the function and removed the argument.
* Get rid of `GHC.Core.TyCon.tyConSingleAlgDataCon_maybe` in favour of calling
`not isNewTyCon` at the call sites; more explicit.
* Refatored `GHC.Core.TyCon.isInjectiveTyCon`; but I don't think I changed its
behaviour
* Moved `decomposeIPPred` to GHC.Core.Predicate
Compile time performance changes:
geo. mean +0.1%
minimum -6.8%
maximum +14.4%
The +14% one is in T21839c, where it seems that a bit more inlining
is taking place. That seems acceptable; and the average change is small
Metric Decrease:
LargeRecord
T12227
T12707
T16577
T21839r
T5642
Metric Increase:
T15164
T21839c
T3294
T5321FD
T5321Fun
WWRec
- - - - -
9bf00666 by Simon Peyton Jones at 2025-08-13T13:02:46-04:00
Slight improvement to pre/postInlineUnconditionally
Avoids an extra simplifier iteration
- - - - -
60db2c66 by Simon Peyton Jones at 2025-08-13T13:02:46-04:00
Fix a long-standing assertion error in normSplitTyConApp_maybe
- - - - -
b2b95dce by Simon Peyton Jones at 2025-08-13T13:02:46-04:00
Add comment to coercion optimiser
- - - - -
166 changed files:
- compiler/GHC/Builtin/Names.hs
- compiler/GHC/Builtin/PrimOps/Ids.hs
- compiler/GHC/Builtin/Types.hs
- compiler/GHC/Builtin/Types/Prim.hs
- compiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/ByteCode/InfoTable.hs
- compiler/GHC/Core/Class.hs
- compiler/GHC/Core/Coercion.hs
- compiler/GHC/Core/Coercion/Opt.hs
- compiler/GHC/Core/DataCon.hs
- compiler/GHC/Core/FamInstEnv.hs
- compiler/GHC/Core/Opt/Arity.hs
- compiler/GHC/Core/Opt/CprAnal.hs
- compiler/GHC/Core/Opt/DmdAnal.hs
- compiler/GHC/Core/Opt/OccurAnal.hs
- compiler/GHC/Core/Opt/SetLevels.hs
- compiler/GHC/Core/Opt/Simplify/Utils.hs
- compiler/GHC/Core/Opt/Specialise.hs
- compiler/GHC/Core/Opt/WorkWrap/Utils.hs
- compiler/GHC/Core/Predicate.hs
- compiler/GHC/Core/TyCo/Rep.hs
- compiler/GHC/Core/TyCon.hs
- compiler/GHC/Core/Type.hs
- compiler/GHC/Core/Unfold.hs
- compiler/GHC/Core/Unfold/Make.hs
- compiler/GHC/Core/Utils.hs
- compiler/GHC/CoreToStg.hs
- + compiler/GHC/CoreToStg/AddImplicitBinds.hs
- compiler/GHC/CoreToStg/Prep.hs
- compiler/GHC/Driver/Main.hs
- compiler/GHC/HsToCore.hs
- compiler/GHC/HsToCore/Binds.hs
- compiler/GHC/HsToCore/Expr.hs
- compiler/GHC/HsToCore/Foreign/Call.hs
- compiler/GHC/Iface/Decl.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Iface/Tidy.hs
- compiler/GHC/IfaceToCore.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/StgToByteCode.hs
- compiler/GHC/StgToCmm.hs
- compiler/GHC/StgToCmm/Prim.hs
- compiler/GHC/StgToJS/Prim.hs
- compiler/GHC/Tc/Errors.hs
- compiler/GHC/Tc/Gen/App.hs
- compiler/GHC/Tc/Gen/Bind.hs
- compiler/GHC/Tc/Gen/Expr.hs
- compiler/GHC/Tc/Gen/HsType.hs
- compiler/GHC/Tc/Instance/Class.hs
- compiler/GHC/Tc/Instance/Family.hs
- compiler/GHC/Tc/Solver/Default.hs
- compiler/GHC/Tc/Solver/Dict.hs
- compiler/GHC/Tc/Solver/Equality.hs
- compiler/GHC/Tc/Solver/Monad.hs
- compiler/GHC/Tc/Solver/Solve.hs
- compiler/GHC/Tc/TyCl.hs
- compiler/GHC/Tc/TyCl/Build.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Tc/TyCl/PatSyn.hs
- compiler/GHC/Tc/TyCl/Utils.hs
- − compiler/GHC/Tc/Types/EvTerm.hs
- compiler/GHC/Tc/Types/Evidence.hs
- compiler/GHC/Tc/Types/Origin.hs
- compiler/GHC/Tc/Utils/Concrete.hs
- compiler/GHC/Tc/Utils/TcMType.hs
- compiler/GHC/Tc/Utils/Unify.hs
- compiler/GHC/Types/Demand.hs
- compiler/GHC/Types/Id.hs
- compiler/GHC/Types/Id/Make.hs
- compiler/GHC/Types/RepType.hs
- compiler/GHC/Types/TyThing.hs
- compiler/ghc.cabal.in
- ghc/ghc-bin.cabal.in
- libraries/Cabal
- libraries/base/base.cabal.in
- libraries/base/changelog.md
- libraries/base/src/GHC/Exts.hs
- − libraries/base/src/GHC/IOPort.hs
- libraries/directory
- libraries/ghc-heap/GHC/Exts/Heap/Closures.hs
- libraries/ghc-internal/ghc-internal.cabal.in
- libraries/ghc-internal/src/GHC/Internal/Event/Windows.hsc
- libraries/ghc-internal/src/GHC/Internal/Event/Windows/Thread.hs
- libraries/ghc-internal/src/GHC/Internal/Exts.hs
- libraries/ghc-internal/src/GHC/Internal/IO/Buffer.hs
- libraries/ghc-internal/src/GHC/Internal/IO/Windows/Handle.hsc
- − libraries/ghc-internal/src/GHC/Internal/IOPort.hs
- libraries/ghc-internal/src/GHC/Internal/Prim/PtrEq.hs
- libraries/ghc-prim/changelog.md
- libraries/hpc
- libraries/time
- libraries/unix
- rts/Prelude.h
- rts/PrimOps.cmm
- rts/RtsSymbols.c
- rts/external-symbols.list.in
- rts/include/stg/MiscClosures.h
- rts/include/stg/SMP.h
- rts/posix/ticker/Pthread.c
- rts/posix/ticker/TimerFd.c
- rts/win32/AsyncWinIO.c
- rts/win32/libHSghc-internal.def
- testsuite/tests/core-to-stg/T24124.stderr
- testsuite/tests/corelint/LintEtaExpand.stderr
- testsuite/tests/deSugar/should_compile/T2431.stderr
- testsuite/tests/dmdanal/should_compile/T16029.stdout
- testsuite/tests/dmdanal/sigs/T21119.stderr
- testsuite/tests/dmdanal/sigs/T21888.stderr
- testsuite/tests/ghci.debugger/scripts/break011.stdout
- testsuite/tests/ghci.debugger/scripts/break024.stdout
- testsuite/tests/indexed-types/should_compile/T2238.hs
- testsuite/tests/indexed-types/should_fail/T5439.stderr
- testsuite/tests/interface-stability/base-exports.stdout
- testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
- testsuite/tests/interface-stability/base-exports.stdout-mingw32
- testsuite/tests/interface-stability/base-exports.stdout-ws-32
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout-mingw32
- testsuite/tests/interface-stability/ghc-prim-exports.stdout
- testsuite/tests/interface-stability/ghc-prim-exports.stdout-mingw32
- testsuite/tests/numeric/should_compile/T15547.stderr
- testsuite/tests/numeric/should_compile/T23907.stderr
- + testsuite/tests/numeric/should_run/T18619.hs
- + testsuite/tests/numeric/should_run/T18619.stderr
- testsuite/tests/numeric/should_run/all.T
- testsuite/tests/partial-sigs/should_compile/T10403.stderr
- testsuite/tests/partial-sigs/should_fail/T10615.stderr
- testsuite/tests/primops/should_run/UnliftedIOPort.hs
- testsuite/tests/primops/should_run/all.T
- + testsuite/tests/rep-poly/NoEtaRequired.hs
- testsuite/tests/rep-poly/T21906.stderr
- testsuite/tests/rep-poly/all.T
- testsuite/tests/roles/should_compile/Roles14.stderr
- testsuite/tests/roles/should_compile/Roles3.stderr
- testsuite/tests/roles/should_compile/Roles4.stderr
- testsuite/tests/simplCore/should_compile/DataToTagFamilyScrut.stderr
- testsuite/tests/simplCore/should_compile/T15205.stderr
- testsuite/tests/simplCore/should_compile/T17366.stderr
- testsuite/tests/simplCore/should_compile/T17966.stderr
- testsuite/tests/simplCore/should_compile/T22309.stderr
- testsuite/tests/simplCore/should_compile/T22375DataFamily.stderr
- testsuite/tests/simplCore/should_compile/T23307.stderr
- testsuite/tests/simplCore/should_compile/T23307a.stderr
- testsuite/tests/simplCore/should_compile/T25389.stderr
- testsuite/tests/simplCore/should_compile/T25713.stderr
- testsuite/tests/simplCore/should_compile/T7360.stderr
- testsuite/tests/simplStg/should_compile/T15226b.stderr
- testsuite/tests/tcplugins/CtIdPlugin.hs
- testsuite/tests/typecheck/should_compile/Makefile
- testsuite/tests/typecheck/should_compile/T12763.stderr
- testsuite/tests/typecheck/should_compile/T14774.stdout
- testsuite/tests/typecheck/should_compile/T18406b.stderr
- testsuite/tests/typecheck/should_compile/T18529.stderr
- + testsuite/tests/typecheck/should_compile/T26225.hs
- + testsuite/tests/typecheck/should_compile/T26225b.hs
- testsuite/tests/typecheck/should_compile/all.T
- − testsuite/tests/typecheck/should_fail/T12563.stderr
- testsuite/tests/typecheck/should_fail/T14618.stderr
- testsuite/tests/typecheck/should_fail/T6022.stderr
- testsuite/tests/typecheck/should_fail/T8883.stderr
- testsuite/tests/typecheck/should_fail/all.T
- testsuite/tests/typecheck/should_fail/tcfail140.stderr
- testsuite/tests/unboxedsums/unpack_sums_7.stdout
- testsuite/tests/wasm/should_run/control-flow/LoadCmmGroup.hs
- testsuite/tests/wasm/should_run/control-flow/RunWasm.hs
- utils/genprimopcode/Main.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9e2f2d82e58a7961d36954d512b828…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9e2f2d82e58a7961d36954d512b828…
You're receiving this email because of your account on gitlab.haskell.org.
1
0

13 Aug '25
Ben Gamari pushed new branch wip/drop-thread-runnable at Glasgow Haskell Compiler / GHC
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/tree/wip/drop-thread-runnable
You're receiving this email because of your account on gitlab.haskell.org.
1
0

[Git][ghc/ghc][wip/teo/move-out-bits-of-th-from-ghc-internal] 2 commits: template-haskell: move some identifiers from ghc-internal to template-haskell
by Teo Camarasu (@teo) 13 Aug '25
by Teo Camarasu (@teo) 13 Aug '25
13 Aug '25
Teo Camarasu pushed to branch wip/teo/move-out-bits-of-th-from-ghc-internal at Glasgow Haskell Compiler / GHC
Commits:
95524575 by Teo Camarasu at 2025-08-13T15:44:05+01:00
template-haskell: move some identifiers from ghc-internal to template-haskell
These identifiers are not used internally by the compiler. Therefore we
have no reason for them to be in ghc-internal.
By moving them to template-haskell, we benefit from it being easier to
change them and we avoid having to build them in stage0.
Resolves #26048
- - - - -
4652e8b7 by Teo Camarasu at 2025-08-13T15:44:05+01:00
template-haskell: transfer $infix note to public module
This Haddock note should be in the public facing module
- - - - -
10 changed files:
- libraries/ghc-internal/src/GHC/Internal/TH/Lib.hs
- libraries/ghc-internal/src/GHC/Internal/TH/Lift.hs
- libraries/ghc-internal/src/GHC/Internal/TH/Syntax.hs
- libraries/template-haskell/Language/Haskell/TH/Lib.hs
- libraries/template-haskell/Language/Haskell/TH/Quote.hs
- libraries/template-haskell/Language/Haskell/TH/Syntax.hs
- libraries/template-haskell/tests/all.T
- testsuite/tests/interface-stability/template-haskell-exports.stdout
- testsuite/tests/quasiquotation/T4491/test.T
- testsuite/tests/th/Makefile
Changes:
=====================================
libraries/ghc-internal/src/GHC/Internal/TH/Lib.hs
=====================================
@@ -555,20 +555,6 @@ pragInlD name inline rm phases
pragOpaqueD :: Quote m => Name -> m Dec
pragOpaqueD name = pure $ PragmaD $ OpaqueP name
-{-# DEPRECATED pragSpecD "Please use 'pragSpecED' instead. 'pragSpecD' will be removed in GHC 9.18." #-}
-pragSpecD :: Quote m => Name -> m Type -> Phases -> m Dec
-pragSpecD n ty phases
- = do
- ty1 <- ty
- pure $ PragmaD $ SpecialiseP n ty1 Nothing phases
-
-{-# DEPRECATED pragSpecInlD "Please use 'pragSpecInlED' instead. 'pragSpecInlD' will be removed in GHC 9.18." #-}
-pragSpecInlD :: Quote m => Name -> m Type -> Inline -> Phases -> m Dec
-pragSpecInlD n ty inline phases
- = do
- ty1 <- ty
- pure $ PragmaD $ SpecialiseP n ty1 (Just inline) phases
-
pragSpecED :: Quote m
=> Maybe [m (TyVarBndr ())] -> [m RuleBndr]
-> m Exp
@@ -868,22 +854,6 @@ implicitParamT n t
t' <- t
pure $ ImplicitParamT n t'
-{-# DEPRECATED classP "As of template-haskell-2.10, constraint predicates (Pred) are just types (Type), in keeping with ConstraintKinds. Please use 'conT' and 'appT'." #-}
-classP :: Quote m => Name -> [m Type] -> m Pred
-classP cla tys
- = do
- tysl <- sequenceA tys
- pure (foldl AppT (ConT cla) tysl)
-
-{-# DEPRECATED equalP "As of template-haskell-2.10, constraint predicates (Pred) are just types (Type), in keeping with ConstraintKinds. Please see 'equalityT'." #-}
-equalP :: Quote m => m Type -> m Type -> m Pred
-equalP tleft tright
- = do
- tleft1 <- tleft
- tright1 <- tright
- eqT <- equalityT
- pure (foldl AppT eqT [tleft1, tright1])
-
promotedT :: Quote m => Name -> m Type
promotedT = pure . PromotedT
@@ -906,20 +876,6 @@ noSourceStrictness = pure NoSourceStrictness
sourceLazy = pure SourceLazy
sourceStrict = pure SourceStrict
-{-# DEPRECATED isStrict
- ["Use 'bang'. See https://gitlab.haskell.org/ghc/ghc/wikis/migration/8.0. ",
- "Example usage: 'bang noSourceUnpackedness sourceStrict'"] #-}
-{-# DEPRECATED notStrict
- ["Use 'bang'. See https://gitlab.haskell.org/ghc/ghc/wikis/migration/8.0. ",
- "Example usage: 'bang noSourceUnpackedness noSourceStrictness'"] #-}
-{-# DEPRECATED unpacked
- ["Use 'bang'. See https://gitlab.haskell.org/ghc/ghc/wikis/migration/8.0. ",
- "Example usage: 'bang sourceUnpack sourceStrict'"] #-}
-isStrict, notStrict, unpacked :: Quote m => m Strict
-isStrict = bang noSourceUnpackedness sourceStrict
-notStrict = bang noSourceUnpackedness noSourceStrictness
-unpacked = bang sourceUnpack sourceStrict
-
bang :: Quote m => m SourceUnpackedness -> m SourceStrictness -> m Bang
bang u s = do u' <- u
s' <- s
@@ -931,16 +887,6 @@ bangType = liftA2 (,)
varBangType :: Quote m => Name -> m BangType -> m VarBangType
varBangType v bt = (\(b, t) -> (v, b, t)) <$> bt
-{-# DEPRECATED strictType
- "As of @template-haskell-2.11.0.0@, 'StrictType' has been replaced by 'BangType'. Please use 'bangType' instead." #-}
-strictType :: Quote m => m Strict -> m Type -> m StrictType
-strictType = bangType
-
-{-# DEPRECATED varStrictType
- "As of @template-haskell-2.11.0.0@, 'VarStrictType' has been replaced by 'VarBangType'. Please use 'varBangType' instead." #-}
-varStrictType :: Quote m => Name -> m StrictType -> m VarStrictType
-varStrictType = varBangType
-
-- * Type Literals
-- MonadFail here complicates things (a lot) because it would mean we would
=====================================
libraries/ghc-internal/src/GHC/Internal/TH/Lift.hs
=====================================
@@ -24,40 +24,22 @@
module GHC.Internal.TH.Lift
( Lift(..)
- -- * Generic Lift implementations
- , dataToQa
- , dataToCodeQ
- , dataToExpQ
- , liftDataTyped
- , liftData
- , dataToPatQ
-- * Wired-in names
, liftString
- , trueName
- , falseName
- , nothingName
- , justName
- , leftName
- , rightName
- , nonemptyName
)
where
import GHC.Internal.TH.Syntax
import qualified GHC.Internal.TH.Lib as Lib (litE) -- See wrinkle (W4) of Note [Tracking dependencies on primitives]
-import GHC.Internal.Lexeme ( startsVarSym, startsVarId )
import GHC.Internal.Data.Either
-import GHC.Internal.Type.Reflection
import GHC.Internal.Data.Bool
import GHC.Internal.Base hiding (NonEmpty(..), Type, Module, inline)
-import GHC.Internal.Data.Foldable
import GHC.Internal.Data.NonEmpty (NonEmpty(..))
import GHC.Internal.Integer
import GHC.Internal.Real
import GHC.Internal.Word
import GHC.Internal.Int
-import GHC.Internal.Data.Data hiding (Fixity)
import GHC.Internal.Natural
import GHC.Internal.ForeignPtr
@@ -294,20 +276,6 @@ deriving instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f)
deriving instance (Lift a, Lift b, Lift c, Lift d, Lift e, Lift f, Lift g)
=> Lift (# a | b | c | d | e | f | g #)
-trueName, falseName :: Name
-trueName = 'True
-falseName = 'False
-
-nothingName, justName :: Name
-nothingName = 'Nothing
-justName = 'Just
-
-leftName, rightName :: Name
-leftName = 'Left
-rightName = 'Right
-
-nonemptyName :: Name
-nonemptyName = '(:|)
-----------------------------------------------------
--
@@ -443,157 +411,3 @@ deriving instance Lift Info
deriving instance Lift AnnLookup
-- | @since template-haskell-2.22.1.0
deriving instance Lift Extension
-
------------------------------------------------------
---
--- Generic Lift implementations
---
------------------------------------------------------
-
--- | 'dataToQa' is an internal utility function for constructing generic
--- conversion functions from types with 'Data' instances to various
--- quasi-quoting representations. See the source of 'dataToExpQ' and
--- 'dataToPatQ' for two example usages: @mkCon@, @mkLit@
--- and @appQ@ are overloadable to account for different syntax for
--- expressions and patterns; @antiQ@ allows you to override type-specific
--- cases, a common usage is just @const Nothing@, which results in
--- no overloading.
-dataToQa :: forall m a k q. (Quote m, Data a)
- => (Name -> k)
- -> (Lit -> m q)
- -> (k -> [m q] -> m q)
- -> (forall b . Data b => b -> Maybe (m q))
- -> a
- -> m q
-dataToQa mkCon mkLit appCon antiQ t =
- case antiQ t of
- Nothing ->
- case constrRep constr of
- AlgConstr _ ->
- appCon (mkCon funOrConName) conArgs
- where
- funOrConName :: Name
- funOrConName =
- case showConstr constr of
- "(:)" -> Name (mkOccName ":")
- (NameG DataName
- (mkPkgName "ghc-internal")
- (mkModName "GHC.Internal.Types"))
- con@"[]" -> Name (mkOccName con)
- (NameG DataName
- (mkPkgName "ghc-internal")
- (mkModName "GHC.Internal.Types"))
- con@('(':_) -> Name (mkOccName con)
- (NameG DataName
- (mkPkgName "ghc-internal")
- (mkModName "GHC.Internal.Tuple"))
-
- -- Tricky case: see Note [Data for non-algebraic types]
- fun@(x:_) | startsVarSym x || startsVarId x
- -> mkNameG_v tyconPkg tyconMod fun
- con -> mkNameG_d tyconPkg tyconMod con
-
- where
- tycon :: TyCon
- tycon = (typeRepTyCon . typeOf) t
-
- tyconPkg, tyconMod :: String
- tyconPkg = tyConPackage tycon
- tyconMod = tyConModule tycon
-
- conArgs :: [m q]
- conArgs = gmapQ (dataToQa mkCon mkLit appCon antiQ) t
- IntConstr n ->
- mkLit $ IntegerL n
- FloatConstr n ->
- mkLit $ RationalL n
- CharConstr c ->
- mkLit $ CharL c
- where
- constr :: Constr
- constr = toConstr t
-
- Just y -> y
-
-
-{- Note [Data for non-algebraic types]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Class Data was originally intended for algebraic data types. But
-it is possible to use it for abstract types too. For example, in
-package `text` we find
-
- instance Data Text where
- ...
- toConstr _ = packConstr
-
- packConstr :: Constr
- packConstr = mkConstr textDataType "pack" [] Prefix
-
-Here `packConstr` isn't a real data constructor, it's an ordinary
-function. Two complications
-
-* In such a case, we must take care to build the Name using
- mkNameG_v (for values), not mkNameG_d (for data constructors).
- See #10796.
-
-* The pseudo-constructor is named only by its string, here "pack".
- But 'dataToQa' needs the TyCon of its defining module, and has
- to assume it's defined in the same module as the TyCon itself.
- But nothing enforces that; #12596 shows what goes wrong if
- "pack" is defined in a different module than the data type "Text".
- -}
-
--- | A typed variant of 'dataToExpQ'.
-dataToCodeQ :: (Quote m, Data a)
- => (forall b . Data b => b -> Maybe (Code m b))
- -> a -> Code m a
-dataToCodeQ f = unsafeCodeCoerce . dataToExpQ (fmap unTypeCode . f)
-
--- | 'dataToExpQ' converts a value to a 'Exp' representation of the
--- same value, in the SYB style. It is generalized to take a function
--- override type-specific cases; see 'liftData' for a more commonly
--- used variant.
-dataToExpQ :: (Quote m, Data a)
- => (forall b . Data b => b -> Maybe (m Exp))
- -> a
- -> m Exp
-dataToExpQ = dataToQa varOrConE litE (foldl appE)
- where
- -- Make sure that VarE is used if the Constr value relies on a
- -- function underneath the surface (instead of a constructor).
- -- See #10796.
- varOrConE s =
- case nameSpace s of
- Just VarName -> return (VarE s)
- Just (FldName {}) -> return (VarE s)
- Just DataName -> return (ConE s)
- _ -> error $ "Can't construct an expression from name "
- ++ showName s
- appE x y = do { a <- x; b <- y; return (AppE a b)}
- litE c = return (LitE c)
-
--- | A typed variant of 'liftData'.
-liftDataTyped :: (Quote m, Data a) => a -> Code m a
-liftDataTyped = dataToCodeQ (const Nothing)
-
--- | 'liftData' is a variant of 'lift' in the 'Lift' type class which
--- works for any type with a 'Data' instance.
-liftData :: (Quote m, Data a) => a -> m Exp
-liftData = dataToExpQ (const Nothing)
-
--- | 'dataToPatQ' converts a value to a 'Pat' representation of the same
--- value, in the SYB style. It takes a function to handle type-specific cases,
--- alternatively, pass @const Nothing@ to get default behavior.
-dataToPatQ :: (Quote m, Data a)
- => (forall b . Data b => b -> Maybe (m Pat))
- -> a
- -> m Pat
-dataToPatQ = dataToQa id litP conP
- where litP l = return (LitP l)
- conP n ps =
- case nameSpace n of
- Just DataName -> do
- ps' <- sequence ps
- return (ConP n [] ps')
- _ -> error $ "Can't construct a pattern from name "
- ++ showName n
=====================================
libraries/ghc-internal/src/GHC/Internal/TH/Syntax.hs
=====================================
@@ -22,9 +22,6 @@ module GHC.Internal.TH.Syntax
-- * Language extensions
, module GHC.Internal.LanguageExtensions
, ForeignSrcLang(..)
- -- * Notes
- -- ** Unresolved Infix
- -- $infix
) where
#ifdef BOOTSTRAP_TH
@@ -847,12 +844,6 @@ addTempFile suffix = Q (qAddTempFile suffix)
addTopDecls :: [Dec] -> Q ()
addTopDecls ds = Q (qAddTopDecls ds)
--- |
-addForeignFile :: ForeignSrcLang -> String -> Q ()
-addForeignFile = addForeignSource
-{-# DEPRECATED addForeignFile
- "Use 'Language.Haskell.TH.Syntax.addForeignSource' instead"
- #-} -- deprecated in 8.6
-- | Emit a foreign file which will be compiled and linked to the object for
-- the current module. Currently only languages that can be compiled with
@@ -1614,73 +1605,6 @@ maxPrecedence = (9::Int)
defaultFixity :: Fixity
defaultFixity = Fixity maxPrecedence InfixL
-
-{-
-Note [Unresolved infix]
-~~~~~~~~~~~~~~~~~~~~~~~
--}
-{- $infix #infix#
-
-When implementing antiquotation for quasiquoters, one often wants
-to parse strings into expressions:
-
-> parse :: String -> Maybe Exp
-
-But how should we parse @a + b * c@? If we don't know the fixities of
-@+@ and @*@, we don't know whether to parse it as @a + (b * c)@ or @(a
-+ b) * c@.
-
-In cases like this, use 'UInfixE', 'UInfixP', 'UInfixT', or 'PromotedUInfixT',
-which stand for \"unresolved infix expression / pattern / type / promoted
-constructor\", respectively. When the compiler is given a splice containing a
-tree of @UInfixE@ applications such as
-
-> UInfixE
-> (UInfixE e1 op1 e2)
-> op2
-> (UInfixE e3 op3 e4)
-
-it will look up and the fixities of the relevant operators and
-reassociate the tree as necessary.
-
- * trees will not be reassociated across 'ParensE', 'ParensP', or 'ParensT',
- which are of use for parsing expressions like
-
- > (a + b * c) + d * e
-
- * 'InfixE', 'InfixP', 'InfixT', and 'PromotedInfixT' expressions are never
- reassociated.
-
- * The 'UInfixE' constructor doesn't support sections. Sections
- such as @(a *)@ have no ambiguity, so 'InfixE' suffices. For longer
- sections such as @(a + b * c -)@, use an 'InfixE' constructor for the
- outer-most section, and use 'UInfixE' constructors for all
- other operators:
-
- > InfixE
- > Just (UInfixE ...a + b * c...)
- > op
- > Nothing
-
- Sections such as @(a + b +)@ and @((a + b) +)@ should be rendered
- into 'Exp's differently:
-
- > (+ a + b) ---> InfixE Nothing + (Just $ UInfixE a + b)
- > -- will result in a fixity error if (+) is left-infix
- > (+ (a + b)) ---> InfixE Nothing + (Just $ ParensE $ UInfixE a + b)
- > -- no fixity errors
-
- * Quoted expressions such as
-
- > [| a * b + c |] :: Q Exp
- > [p| a : b : c |] :: Q Pat
- > [t| T + T |] :: Q Type
-
- will never contain 'UInfixE', 'UInfixP', 'UInfixT', 'PromotedUInfixT',
- 'InfixT', 'PromotedInfixT, 'ParensE', 'ParensP', or 'ParensT' constructors.
-
--}
-
-----------------------------------------------------
--
-- The main syntax data types
=====================================
libraries/template-haskell/Language/Haskell/TH/Lib.hs
=====================================
@@ -395,3 +395,66 @@ mdoE = Internal.mdoE Nothing
conP :: Quote m => Name -> [m Pat] -> m Pat
conP n xs = Internal.conP n [] xs
+
+
+--------------------------------------------------------------------------------
+-- * Constraint predicates (deprecated)
+
+{-# DEPRECATED classP "As of template-haskell-2.10, constraint predicates (Pred) are just types (Type), in keeping with ConstraintKinds. Please use 'conT' and 'appT'." #-}
+classP :: Quote m => Name -> [m Type] -> m Pred
+classP cla tys
+ = do
+ tysl <- sequenceA tys
+ pure (foldl AppT (ConT cla) tysl)
+
+{-# DEPRECATED equalP "As of template-haskell-2.10, constraint predicates (Pred) are just types (Type), in keeping with ConstraintKinds. Please see 'equalityT'." #-}
+equalP :: Quote m => m Type -> m Type -> m Pred
+equalP tleft tright
+ = do
+ tleft1 <- tleft
+ tright1 <- tright
+ eqT <- equalityT
+ pure (foldl AppT eqT [tleft1, tright1])
+
+--------------------------------------------------------------------------------
+-- * Strictness queries (deprecated)
+{-# DEPRECATED isStrict
+ ["Use 'bang'. See https://gitlab.haskell.org/ghc/ghc/wikis/migration/8.0. ",
+ "Example usage: 'bang noSourceUnpackedness sourceStrict'"] #-}
+{-# DEPRECATED notStrict
+ ["Use 'bang'. See https://gitlab.haskell.org/ghc/ghc/wikis/migration/8.0. ",
+ "Example usage: 'bang noSourceUnpackedness noSourceStrictness'"] #-}
+{-# DEPRECATED unpacked
+ ["Use 'bang'. See https://gitlab.haskell.org/ghc/ghc/wikis/migration/8.0. ",
+ "Example usage: 'bang sourceUnpack sourceStrict'"] #-}
+isStrict, notStrict, unpacked :: Quote m => m Strict
+isStrict = bang noSourceUnpackedness sourceStrict
+notStrict = bang noSourceUnpackedness noSourceStrictness
+unpacked = bang sourceUnpack sourceStrict
+
+{-# DEPRECATED strictType
+ "As of @template-haskell-2.11.0.0@, 'StrictType' has been replaced by 'BangType'. Please use 'bangType' instead." #-}
+strictType :: Quote m => m Strict -> m Type -> m StrictType
+strictType = bangType
+
+{-# DEPRECATED varStrictType
+ "As of @template-haskell-2.11.0.0@, 'VarStrictType' has been replaced by 'VarBangType'. Please use 'varBangType' instead." #-}
+varStrictType :: Quote m => Name -> m StrictType -> m VarStrictType
+varStrictType = varBangType
+
+--------------------------------------------------------------------------------
+-- * Specialisation pragmas (deprecated)
+
+{-# DEPRECATED pragSpecD "Please use 'pragSpecED' instead. 'pragSpecD' will be removed in GHC 9.18." #-}
+pragSpecD :: Quote m => Name -> m Type -> Phases -> m Dec
+pragSpecD n ty phases
+ = do
+ ty1 <- ty
+ pure $ PragmaD $ SpecialiseP n ty1 Nothing phases
+
+{-# DEPRECATED pragSpecInlD "Please use 'pragSpecInlED' instead. 'pragSpecInlD' will be removed in GHC 9.18." #-}
+pragSpecInlD :: Quote m => Name -> m Type -> Inline -> Phases -> m Dec
+pragSpecInlD n ty inline phases
+ = do
+ ty1 <- ty
+ pure $ PragmaD $ SpecialiseP n ty1 (Just inline) phases
=====================================
libraries/template-haskell/Language/Haskell/TH/Quote.hs
=====================================
@@ -19,12 +19,12 @@ module Language.Haskell.TH.Quote
, namedDefaultQuasiQuoter
, defaultQuasiQuoter
-- * For backwards compatibility
- ,dataToQa, dataToExpQ, dataToPatQ
+ , dataToQa, dataToExpQ, dataToPatQ
) where
import GHC.Boot.TH.Syntax
import GHC.Boot.TH.Quote
-import GHC.Boot.TH.Lift
+import Language.Haskell.TH.Syntax (dataToQa, dataToExpQ, dataToPatQ)
-- | 'quoteFile' takes a 'QuasiQuoter' and lifts it into one that read
=====================================
libraries/template-haskell/Language/Haskell/TH/Syntax.hs
=====================================
@@ -1,6 +1,8 @@
{-# LANGUAGE MagicHash #-}
+{-# LANGUAGE RankNTypes #-}
+{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskellQuotes #-}
-{-# LANGUAGE Safe #-}
+{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE UnboxedTuples #-}
module Language.Haskell.TH.Syntax (
@@ -190,19 +192,267 @@ module Language.Haskell.TH.Syntax (
nothingName,
rightName,
trueName,
+ -- * Notes
+ -- ** Unresolved Infix
+ -- $infix
)
where
import GHC.Boot.TH.Lift
import GHC.Boot.TH.Syntax
import System.FilePath
+import Data.Data hiding (Fixity(..))
+import Data.List.NonEmpty (NonEmpty(..))
+import GHC.Lexeme ( startsVarSym, startsVarId )
-- This module completely re-exports 'GHC.Boot.TH.Syntax',
-- and exports additionally functions that depend on filepath.
+-- |
+addForeignFile :: ForeignSrcLang -> String -> Q ()
+addForeignFile = addForeignSource
+{-# DEPRECATED addForeignFile
+ "Use 'Language.Haskell.TH.Syntax.addForeignSource' instead"
+ #-} -- deprecated in 8.6
+
-- | The input is a filepath, which if relative is offset by the package root.
makeRelativeToProject :: FilePath -> Q FilePath
makeRelativeToProject fp | isRelative fp = do
root <- getPackageRoot
return (root </> fp)
makeRelativeToProject fp = return fp
+
+trueName, falseName :: Name
+trueName = 'True
+falseName = 'False
+
+nothingName, justName :: Name
+nothingName = 'Nothing
+justName = 'Just
+
+leftName, rightName :: Name
+leftName = 'Left
+rightName = 'Right
+
+nonemptyName :: Name
+nonemptyName = '(:|)
+
+-----------------------------------------------------
+--
+-- Generic Lift implementations
+--
+-----------------------------------------------------
+
+-- | 'dataToQa' is an internal utility function for constructing generic
+-- conversion functions from types with 'Data' instances to various
+-- quasi-quoting representations. See the source of 'dataToExpQ' and
+-- 'dataToPatQ' for two example usages: @mkCon@, @mkLit@
+-- and @appQ@ are overloadable to account for different syntax for
+-- expressions and patterns; @antiQ@ allows you to override type-specific
+-- cases, a common usage is just @const Nothing@, which results in
+-- no overloading.
+dataToQa :: forall m a k q. (Quote m, Data a)
+ => (Name -> k)
+ -> (Lit -> m q)
+ -> (k -> [m q] -> m q)
+ -> (forall b . Data b => b -> Maybe (m q))
+ -> a
+ -> m q
+dataToQa mkCon mkLit appCon antiQ t =
+ case antiQ t of
+ Nothing ->
+ case constrRep constr of
+ AlgConstr _ ->
+ appCon (mkCon funOrConName) conArgs
+ where
+ funOrConName :: Name
+ funOrConName =
+ case showConstr constr of
+ "(:)" -> Name (mkOccName ":")
+ (NameG DataName
+ (mkPkgName "ghc-internal")
+ (mkModName "GHC.Internal.Types"))
+ con@"[]" -> Name (mkOccName con)
+ (NameG DataName
+ (mkPkgName "ghc-internal")
+ (mkModName "GHC.Internal.Types"))
+ con@('(':_) -> Name (mkOccName con)
+ (NameG DataName
+ (mkPkgName "ghc-internal")
+ (mkModName "GHC.Internal.Tuple"))
+
+ -- Tricky case: see Note [Data for non-algebraic types]
+ fun@(x:_) | startsVarSym x || startsVarId x
+ -> mkNameG_v tyconPkg tyconMod fun
+ con -> mkNameG_d tyconPkg tyconMod con
+
+ where
+ tycon :: TyCon
+ tycon = (typeRepTyCon . typeOf) t
+
+ tyconPkg, tyconMod :: String
+ tyconPkg = tyConPackage tycon
+ tyconMod = tyConModule tycon
+
+ conArgs :: [m q]
+ conArgs = gmapQ (dataToQa mkCon mkLit appCon antiQ) t
+ IntConstr n ->
+ mkLit $ IntegerL n
+ FloatConstr n ->
+ mkLit $ RationalL n
+ CharConstr c ->
+ mkLit $ CharL c
+ where
+ constr :: Constr
+ constr = toConstr t
+
+ Just y -> y
+
+
+{- Note [Data for non-algebraic types]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Class Data was originally intended for algebraic data types. But
+it is possible to use it for abstract types too. For example, in
+package `text` we find
+
+ instance Data Text where
+ ...
+ toConstr _ = packConstr
+
+ packConstr :: Constr
+ packConstr = mkConstr textDataType "pack" [] Prefix
+
+Here `packConstr` isn't a real data constructor, it's an ordinary
+function. Two complications
+
+* In such a case, we must take care to build the Name using
+ mkNameG_v (for values), not mkNameG_d (for data constructors).
+ See #10796.
+
+* The pseudo-constructor is named only by its string, here "pack".
+ But 'dataToQa' needs the TyCon of its defining module, and has
+ to assume it's defined in the same module as the TyCon itself.
+ But nothing enforces that; #12596 shows what goes wrong if
+ "pack" is defined in a different module than the data type "Text".
+ -}
+
+-- | A typed variant of 'dataToExpQ'.
+dataToCodeQ :: (Quote m, Data a)
+ => (forall b . Data b => b -> Maybe (Code m b))
+ -> a -> Code m a
+dataToCodeQ f = unsafeCodeCoerce . dataToExpQ (fmap unTypeCode . f)
+
+-- | 'dataToExpQ' converts a value to a 'Exp' representation of the
+-- same value, in the SYB style. It is generalized to take a function
+-- override type-specific cases; see 'liftData' for a more commonly
+-- used variant.
+dataToExpQ :: (Quote m, Data a)
+ => (forall b . Data b => b -> Maybe (m Exp))
+ -> a
+ -> m Exp
+dataToExpQ = dataToQa varOrConE litE (foldl appE)
+ where
+ -- Make sure that VarE is used if the Constr value relies on a
+ -- function underneath the surface (instead of a constructor).
+ -- See #10796.
+ varOrConE s =
+ case nameSpace s of
+ Just VarName -> return (VarE s)
+ Just (FldName {}) -> return (VarE s)
+ Just DataName -> return (ConE s)
+ _ -> error $ "Can't construct an expression from name "
+ ++ showName s
+ appE x y = do { a <- x; b <- y; return (AppE a b)}
+ litE c = return (LitE c)
+
+-- | A typed variant of 'liftData'.
+liftDataTyped :: (Quote m, Data a) => a -> Code m a
+liftDataTyped = dataToCodeQ (const Nothing)
+
+-- | 'liftData' is a variant of 'lift' in the 'Lift' type class which
+-- works for any type with a 'Data' instance.
+liftData :: (Quote m, Data a) => a -> m Exp
+liftData = dataToExpQ (const Nothing)
+
+-- | 'dataToPatQ' converts a value to a 'Pat' representation of the same
+-- value, in the SYB style. It takes a function to handle type-specific cases,
+-- alternatively, pass @const Nothing@ to get default behavior.
+dataToPatQ :: (Quote m, Data a)
+ => (forall b . Data b => b -> Maybe (m Pat))
+ -> a
+ -> m Pat
+dataToPatQ = dataToQa id litP conP
+ where litP l = return (LitP l)
+ conP n ps =
+ case nameSpace n of
+ Just DataName -> do
+ ps' <- sequence ps
+ return (ConP n [] ps')
+ _ -> error $ "Can't construct a pattern from name "
+ ++ showName n
+
+{-
+Note [Unresolved infix]
+~~~~~~~~~~~~~~~~~~~~~~~
+-}
+{- $infix #infix#
+
+When implementing antiquotation for quasiquoters, one often wants
+to parse strings into expressions:
+
+> parse :: String -> Maybe Exp
+
+But how should we parse @a + b * c@? If we don't know the fixities of
+@+@ and @*@, we don't know whether to parse it as @a + (b * c)@ or @(a
++ b) * c@.
+
+In cases like this, use 'UInfixE', 'UInfixP', 'UInfixT', or 'PromotedUInfixT',
+which stand for \"unresolved infix expression / pattern / type / promoted
+constructor\", respectively. When the compiler is given a splice containing a
+tree of @UInfixE@ applications such as
+
+> UInfixE
+> (UInfixE e1 op1 e2)
+> op2
+> (UInfixE e3 op3 e4)
+
+it will look up and the fixities of the relevant operators and
+reassociate the tree as necessary.
+
+ * trees will not be reassociated across 'ParensE', 'ParensP', or 'ParensT',
+ which are of use for parsing expressions like
+
+ > (a + b * c) + d * e
+
+ * 'InfixE', 'InfixP', 'InfixT', and 'PromotedInfixT' expressions are never
+ reassociated.
+
+ * The 'UInfixE' constructor doesn't support sections. Sections
+ such as @(a *)@ have no ambiguity, so 'InfixE' suffices. For longer
+ sections such as @(a + b * c -)@, use an 'InfixE' constructor for the
+ outer-most section, and use 'UInfixE' constructors for all
+ other operators:
+
+ > InfixE
+ > Just (UInfixE ...a + b * c...)
+ > op
+ > Nothing
+
+ Sections such as @(a + b +)@ and @((a + b) +)@ should be rendered
+ into 'Exp's differently:
+
+ > (+ a + b) ---> InfixE Nothing + (Just $ UInfixE a + b)
+ > -- will result in a fixity error if (+) is left-infix
+ > (+ (a + b)) ---> InfixE Nothing + (Just $ ParensE $ UInfixE a + b)
+ > -- no fixity errors
+
+ * Quoted expressions such as
+
+ > [| a * b + c |] :: Q Exp
+ > [p| a : b : c |] :: Q Pat
+ > [t| T + T |] :: Q Type
+
+ will never contain 'UInfixE', 'UInfixP', 'UInfixT', 'PromotedUInfixT',
+ 'InfixT', 'PromotedInfixT, 'ParensE', 'ParensP', or 'ParensT' constructors.
+
+-}
=====================================
libraries/template-haskell/tests/all.T
=====================================
@@ -1,4 +1,4 @@
# difficult to test TH with profiling, because we have to build twice
-test('dataToExpQUnit', [omit_ways(prof_ways), req_th], compile, ['-v0'])
-test('dataToCodeQUnit', [omit_ways(prof_ways), req_th], compile, ['-v0'])
+test('dataToExpQUnit', [omit_ways(prof_ways), req_th], compile, ['-package template-haskell -v0'])
+test('dataToCodeQUnit', [omit_ways(prof_ways), req_th], compile, ['-package template-haskell -v0'])
test('pragCompletePpr', [omit_ways(prof_ways), req_th], compile_and_run, [''])
=====================================
testsuite/tests/interface-stability/template-haskell-exports.stdout
=====================================
@@ -1375,7 +1375,7 @@ module Language.Haskell.TH.Quote where
quoteFile :: QuasiQuoter -> QuasiQuoter
module Language.Haskell.TH.Syntax where
- -- Safety: Safe
+ -- Safety: Trustworthy
type AnnLookup :: *
data AnnLookup = AnnLookupModule Module | AnnLookupName Name
type AnnTarget :: *
=====================================
testsuite/tests/quasiquotation/T4491/test.T
=====================================
@@ -7,4 +7,4 @@ test('T4491',
# the TH way
only_ways([config.ghc_th_way]),
],
- compile_and_run, [''])
+ compile_and_run, ['-package template-haskell'])
=====================================
testsuite/tests/th/Makefile
=====================================
@@ -9,8 +9,8 @@ T2386:
'$(TEST_HC)' $(TEST_HC_OPTS) $(ghcThWayFlags) -v0 -c T2386.hs
T7445:
- '$(TEST_HC)' $(TEST_HC_OPTS) $(ghcThWayFlags) -v0 -c T7445a.hs
- '$(TEST_HC)' $(TEST_HC_OPTS) $(ghcThWayFlags) -v0 -c T7445.hs
+ '$(TEST_HC)' $(TEST_HC_OPTS) $(ghcThWayFlags) -package template-haskell -v0 -c T7445a.hs
+ '$(TEST_HC)' $(TEST_HC_OPTS) $(ghcThWayFlags) -package template-haskell -v0 -c T7445.hs
HC_OPTS = -XTemplateHaskell -package template-haskell
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/47533cb1255306dc87671e8e1aa2cf…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/47533cb1255306dc87671e8e1aa2cf…
You're receiving this email because of your account on gitlab.haskell.org.
1
0