[Git][ghc/ghc][wip/clc216] 4 commits: haddock: decrease margin on top of small headings
Rodrigo Mesquita (@alt-romes)
gitlab at gitlab.haskell.org
Wed Aug 7 14:52:07 UTC 2024
Rodrigo Mesquita pushed to branch wip/clc216 at Glasgow Haskell Compiler / GHC
Commits:
af2ae742 by M. Taimoor Zaeem at 2024-08-03T18:52:50+05:00
haddock: decrease margin on top of small headings
- - - - -
a1e42e7a by Rodrigo Mesquita at 2024-08-05T21:03:04-04:00
hi: Deterministic ImportedMods in Usages
The `mi_usages` field of the interface files must use a deterministic
list of `Usage`s to guarantee a deterministic interface. However, this
list was, in its origins, constructed from a `ModuleEnv` which uses a
non-deterministic ordering that was leaking into the interface.
Specifically, ImportedMods = ModuleEnv ... would get converted to a list and
then passed to `mkUsageInfo` to construct the Usages.
The solution is simple. Back `ImportedMods` with a deterministic map.
`Map Module ...` is enough, since the Ord instance for `Module` already
uses a stable, deterministic, comparison.
Fixes #25131
- - - - -
dd125849 by Rodrigo Mesquita at 2024-08-07T15:51:55+01:00
ghc-internal: Derive version from ghc's version
Fixes #25005
- - - - -
abbac7ff by Ben Gamari at 2024-08-07T15:51:56+01:00
base: Deprecate GHC.Desugar
See https://github.com/haskell/core-libraries-committee/issues/216.
This will be removed in GHC 9.14.
- - - - -
23 changed files:
- .gitignore
- compiler/GHC/Driver/Main.hs
- compiler/GHC/HsToCore/Docs.hs
- compiler/GHC/HsToCore/Usage.hs
- compiler/GHC/Rename/Names.hs
- compiler/GHC/Rename/Unbound.hs
- compiler/GHC/Tc/Gen/Export.hs
- compiler/GHC/Tc/Gen/Splice.hs
- compiler/GHC/Tc/Module.hs
- compiler/GHC/Tc/Types.hs
- compiler/GHC/Unit/Module/Imported.hs
- compiler/GHC/Unit/Module/ModIface.hs
- hadrian/src/Rules/Generate.hs
- libraries/base/base.cabal
- libraries/base/changelog.md
- libraries/base/src/GHC/Desugar.hs
- libraries/ghc-experimental/ghc-experimental.cabal
- libraries/ghc-heap/ghc-heap.cabal.in
- libraries/ghc-internal/ghc-internal.cabal → libraries/ghc-internal/ghc-internal.cabal.in
- libraries/ghci/GHCi/TH.hs
- libraries/ghci/ghci.cabal.in
- utils/haddock/CHANGES.md
- utils/haddock/haddock-api/resources/html/Linuwial.std-theme/linuwial.css
Changes:
=====================================
.gitignore
=====================================
@@ -169,6 +169,7 @@ _darcs/
/libraries/ghc-boot-th-next/ghc-boot-th-next.cabal
/libraries/ghc-boot-th/ghc.mk
/libraries/ghc-heap/ghc-heap.cabal
+/libraries/ghc-internal/ghc-internal.cabal
/libraries/ghci/GNUmakefile
/libraries/ghci/ghci.cabal
/libraries/ghci/ghc.mk
=====================================
compiler/GHC/Driver/Main.hs
=====================================
@@ -1489,7 +1489,7 @@ checkSafeImports tcg_env
where
impInfo = tcg_imports tcg_env -- ImportAvails
imports = imp_mods impInfo -- ImportedMods
- imports1 = moduleEnvToList imports -- (Module, [ImportedBy])
+ imports1 = M.toList imports -- (Module, [ImportedBy])
imports' = map (fmap importedByUser) imports1 -- (Module, [ImportedModsVal])
pkgReqs = imp_trust_pkgs impInfo -- [Unit]
=====================================
compiler/GHC/HsToCore/Docs.hs
=====================================
@@ -34,7 +34,6 @@ import GHC.IORef (readIORef)
import GHC.Unit.Types
import GHC.Hs
import GHC.Types.Avail
-import GHC.Unit.Module
import qualified Data.List.NonEmpty as NonEmpty
import Data.List.NonEmpty (NonEmpty ((:|)))
import GHC.Unit.Module.Imported
@@ -183,13 +182,12 @@ mkDocStructureFromExportList mdl import_avails export_list =
aliasMap =
M.fromListWith (<>) $
(this_mdl_name, this_mdl_name :| [])
- : (flip concatMap (moduleEnvToList imported) $ \(mdl, imvs) ->
+ : (flip concatMap (M.toList imported) $ \(mdl, imvs) ->
[(imv_name imv, moduleName mdl :| []) | imv <- imvs])
where
this_mdl_name = moduleName mdl
- imported :: ModuleEnv [ImportedModsVal]
- imported = mapModuleEnv importedByUser (imp_mods import_avails)
+ imported = M.map importedByUser (imp_mods import_avails)
-- | Figure out the documentation structure by correlating
-- the module exports with the located declarations.
=====================================
compiler/GHC/HsToCore/Usage.hs
=====================================
@@ -208,7 +208,7 @@ mk_mod_usage_info uc home_unit home_unit_ids this_mod direct_imports used_names
safe_implicit_imps_req = uc_safe_implicit_imps_req uc
used_mods = moduleEnvKeys ent_map
- dir_imp_mods = moduleEnvKeys direct_imports
+ dir_imp_mods = Map.keys direct_imports
all_mods = used_mods ++ filter (`notElem` used_mods) dir_imp_mods
usage_mods = sortBy stableModuleCmp all_mods
-- canonical order is imported, to avoid interface-file
@@ -289,7 +289,7 @@ mk_mod_usage_info uc home_unit home_unit_ids this_mod direct_imports used_names
by_is_safe (ImportedByUser imv) = imv_is_safe imv
by_is_safe _ = False
(is_direct_import, imp_safe)
- = case lookupModuleEnv direct_imports mod of
+ = case Map.lookup mod direct_imports of
-- ezyang: I'm not sure if any is the correct
-- metric here. If safety was guaranteed to be uniform
-- across all imports, why did the old code only look
=====================================
compiler/GHC/Rename/Names.hs
=====================================
@@ -573,7 +573,7 @@ calculateAvails home_unit other_home_units iface mod_safe' want_boot imported_by
in ImportAvails {
- imp_mods = unitModuleEnv (mi_module iface) [imported_by],
+ imp_mods = Map.singleton (mi_module iface) [imported_by],
imp_orphs = orphans,
imp_finsts = finsts,
imp_sig_mods = sig_mods,
=====================================
compiler/GHC/Rename/Unbound.hs
=====================================
@@ -66,6 +66,7 @@ import Data.List (sortBy, partition, nub)
import Data.List.NonEmpty ( pattern (:|), NonEmpty )
import Data.Function ( on )
import qualified Data.Semigroup as S
+import qualified Data.Map as M
{-
************************************************************************
@@ -339,7 +340,7 @@ importSuggestions looking_for global_env hpt currMod imports rdr_name
-- What import statements provide "Mod" at all
-- or, if this is an unqualified name, are not qualified imports
interesting_imports = [ (mod, imp)
- | (mod, mod_imports) <- moduleEnvToList (imp_mods imports)
+ | (mod, mod_imports) <- M.toList (imp_mods imports)
, Just imp <- return $ pick (importedByUser mod_imports)
]
=====================================
compiler/GHC/Tc/Gen/Export.hs
=====================================
@@ -52,6 +52,7 @@ import Control.Monad ( when )
import qualified Data.List.NonEmpty as NE
import Data.Traversable ( for )
import Data.List ( sortBy )
+import qualified Data.Map as Map
{-
************************************************************************
@@ -307,7 +308,7 @@ exports_from_avail (Just (L _ rdr_items)) rdr_env imports this_mod
= [gre]
imported_modules = [ imv_name imv
- | xs <- moduleEnvElts $ imp_mods imports
+ | xs <- Map.elems $ imp_mods imports
, imv <- importedByUser xs ]
exports_from_item :: ExportAccum -> LIE GhcPs
=====================================
compiler/GHC/Tc/Gen/Splice.hs
=====================================
@@ -136,8 +136,8 @@ import qualified GHC.Internal.TH.Syntax as TH
import qualified GHC.Internal.TH.Ppr as TH
#if defined(HAVE_INTERNAL_INTERPRETER)
--- Because GHC.Desugar might not be in the base library of the bootstrapping compiler
-import GHC.Desugar ( AnnotationWrapper(..) )
+-- Because GHC.Internal.Desugar might not be in the base library of the bootstrapping compiler
+import GHC.Internal.Desugar ( AnnotationWrapper(..) )
import Unsafe.Coerce ( unsafeCoerce )
#endif
@@ -2886,7 +2886,7 @@ reifyModule (TH.Module (TH.PkgName pkgString) (TH.ModName mString)) = do
if (reifMod == this_mod) then reifyThisModule else reifyFromIface reifMod
where
reifyThisModule = do
- usages <- fmap (map modToTHMod . moduleEnvKeys . imp_mods) getImports
+ usages <- fmap (map modToTHMod . Map.keys . imp_mods) getImports
return $ TH.ModuleInfo usages
reifyFromIface reifMod = do
=====================================
compiler/GHC/Tc/Module.hs
=====================================
@@ -178,6 +178,7 @@ import Data.List.NonEmpty ( NonEmpty (..) )
import qualified Data.List.NonEmpty as NE
import Data.Ord
import qualified Data.Set as S
+import qualified Data.Map as M
import Data.Foldable ( for_ )
import Data.Traversable ( for )
@@ -432,7 +433,7 @@ tcRnImports hsc_env import_decls
-- Check type-family consistency between imports.
-- See Note [The type family instance consistency story]
; traceRn "rn1: checking family instance consistency {" empty
- ; let { dir_imp_mods = moduleEnvKeys
+ ; let { dir_imp_mods = M.keys
. imp_mods
$ imports }
; checkFamInstConsistency dir_imp_mods
=====================================
compiler/GHC/Tc/Types.hs
=====================================
@@ -176,6 +176,7 @@ import GHCi.RemoteTypes
import Data.Set ( Set )
import qualified Data.Set as S
+import qualified Data.Map as M
import Data.Dynamic ( Dynamic )
import Data.Map ( Map )
import Data.Typeable ( TypeRep )
@@ -916,7 +917,7 @@ plusModDeps = plusInstalledModuleEnv plus_mod_dep
-- perf/compiler/MultiLayerModules
emptyImportAvails :: ImportAvails
-emptyImportAvails = ImportAvails { imp_mods = emptyModuleEnv,
+emptyImportAvails = ImportAvails { imp_mods = M.empty,
imp_direct_dep_mods = emptyInstalledModuleEnv,
imp_dep_direct_pkgs = S.empty,
imp_sig_mods = [],
@@ -947,7 +948,7 @@ plusImportAvails
imp_sig_mods = sig_mods2,
imp_trust_pkgs = tpkgs2, imp_trust_own_pkg = tself2,
imp_orphs = orphs2, imp_finsts = finsts2 })
- = ImportAvails { imp_mods = plusModuleEnv_C (++) mods1 mods2,
+ = ImportAvails { imp_mods = M.unionWith (++) mods1 mods2,
imp_direct_dep_mods = ddmods1 `plusModDeps` ddmods2,
imp_dep_direct_pkgs = ddpkgs1 `S.union` ddpkgs2,
imp_trust_pkgs = tpkgs1 `S.union` tpkgs2,
=====================================
compiler/GHC/Unit/Module/Imported.hs
=====================================
@@ -13,10 +13,13 @@ import GHC.Unit.Module
import GHC.Types.Name.Reader
import GHC.Types.SafeHaskell
import GHC.Types.SrcLoc
+import Data.Map (Map)
-- | Records the modules directly imported by a module for extracting e.g.
-- usage information, and also to give better error message
-type ImportedMods = ModuleEnv [ImportedBy]
+type ImportedMods = Map Module [ImportedBy]
+ -- We don't want to use a `ModuleEnv` since it would leak a non-deterministic
+ -- order to the interface files when passed as a list to `mkUsageInfo`.
-- | If a module was "imported" by the user, we associate it with
-- more detailed usage information 'ImportedModsVal'; a module
=====================================
compiler/GHC/Unit/Module/ModIface.hs
=====================================
@@ -245,6 +245,9 @@ data ModIface_ (phase :: ModIfacePhase)
-- doesn't affect the hash of this module)
-- NOT STRICT! we read this field lazily from the interface file
-- It is *only* consulted by the recompilation checker
+ --
+ -- The elements must be *deterministically* sorted to guarantee
+ -- deterministic interface files
mi_exports_ :: ![IfaceExport],
-- ^ Exports
=====================================
hadrian/src/Rules/Generate.hs
=====================================
@@ -342,6 +342,7 @@ templateRules = do
]
templateRule "libraries/ghci/ghci.cabal" $ projectVersion
templateRule "libraries/ghc-heap/ghc-heap.cabal" $ projectVersion
+ templateRule "libraries/ghc-internal/ghc-internal.cabal" $ projectVersion
templateRule "utils/ghc-pkg/ghc-pkg.cabal" $ projectVersion
templateRule "libraries/template-haskell/template-haskell.cabal" $ mconcat
[ projectVersion
=====================================
libraries/base/base.cabal
=====================================
@@ -26,7 +26,7 @@ Library
default-language: Haskell2010
default-extensions: NoImplicitPrelude
build-depends:
- ghc-internal >= 9.1001 && < 9.1002,
+ ghc-internal >= 9.1101 && < 9.1102,
ghc-prim,
exposed-modules:
@@ -55,6 +55,7 @@ Library
, Data.Ratio
, Data.STRef.Lazy
, Data.Semigroup
+ , GHC.Desugar
, Prelude
, Text.Printf
, System.CPUTime
@@ -156,7 +157,6 @@ Library
, GHC.Conc.Sync
, GHC.ConsoleHandler
, GHC.Constants
- , GHC.Desugar
, GHC.Encoding.UTF8
, GHC.Enum
, GHC.Environment
=====================================
libraries/base/changelog.md
=====================================
@@ -1,6 +1,7 @@
# Changelog for [`base` package](http://hackage.haskell.org/package/base)
## 4.21.0.0 *TBA*
+ * `GHC.Desugar` has been deprecated and should be removed in GHC 9.14. ([CLC proposal #216](https://github.com/haskell/core-libraries-committee/issues/216))
* Add a `readTixFile` field to the `HpcFlags` record in `GHC.RTS.Flags` ([CLC proposal #276](https://github.com/haskell/core-libraries-committee/issues/276))
* Add `compareLength` to `Data.List` and `Data.List.NonEmpty` ([CLC proposal #257](https://github.com/haskell/core-libraries-committee/issues/257))
* Add `INLINE[1]` to `compareInt` / `compareWord` ([CLC proposal #179](https://github.com/haskell/core-libraries-committee/issues/179))
=====================================
libraries/base/src/GHC/Desugar.hs
=====================================
@@ -1,6 +1,8 @@
+{-# LANGUAGE CPP #-}
{-# LANGUAGE Safe #-}
{-# OPTIONS_HADDOCK not-home #-}
+-----------------------------------------------------------------------------
-- |
--
-- Module : GHC.Desugar
@@ -8,7 +10,7 @@
-- License : see libraries/base/LICENSE
--
-- Maintainer : ghc-devs at haskell.org
--- Stability : internal
+-- Stability : deprecated (<https://github.com/haskell/core-libraries-committee/issues/216>)
-- Portability : non-portable (GHC extensions)
--
-- Support code for desugaring in GHC
@@ -18,11 +20,14 @@
-- bound, e.g., @base < 4.X@ rather than @base < 5@, because the interface can
-- change rapidly without much warning.
--
+-----------------------------------------------------------------------------
+
+#if __GLASGOW_HASKELL >= 914
+#error "GHC.Desugar should be removed in GHC 9.14"
+#endif
module GHC.Desugar
- ((>>>),
- AnnotationWrapper(..),
- toAnnotationWrapper
- ) where
+ {-# DEPRECATED ["GHC.Desugar is deprecated and will be removed in GHC 9.14.", "(>>>) should be imported from Control.Arrow.", "AnnotationWrapper is internal to GHC and should not be used externally."] #-}
+ ((>>>), AnnotationWrapper(..), toAnnotationWrapper) where
import GHC.Internal.Desugar
=====================================
libraries/ghc-experimental/ghc-experimental.cabal
=====================================
@@ -33,7 +33,7 @@ library
exposed-modules: GHC.Wasm.Prim
other-extensions:
build-depends: base ^>=4.20,
- ghc-internal >= 9.1001 && < 9.1002,
+ ghc-internal >= 9.1101 && < 9.1102,
ghc-prim >= 0.11 && < 0.12
hs-source-dirs: src
default-language: Haskell2010
=====================================
libraries/ghc-heap/ghc-heap.cabal.in
=====================================
@@ -28,7 +28,7 @@ library
, containers >= 0.6.2.1 && < 0.8
if impl(ghc >= 9.9)
- build-depends: ghc-internal >= 9.1001 && < 9.1002
+ build-depends: ghc-internal >= 9.1101 && < 9.1102
ghc-options: -Wall
if !os(ghcjs)
=====================================
libraries/ghc-internal/ghc-internal.cabal → libraries/ghc-internal/ghc-internal.cabal.in
=====================================
@@ -1,6 +1,10 @@
cabal-version: 3.0
+-- WARNING: ghc-internal.cabal is automatically generated from ghc-internal.cabal.in by
+-- the top-level ./configure script. Make sure you are editing ghc-internal.cabal.in, not ghc-internal.cabal.
name: ghc-internal
-version: 9.1001.0
+-- The project is ghc's version plus ghc-internal's version suffix.
+-- For example, for ghc=9.10, ghc-internal's version will be 9.1001.0.
+version: @ProjectVersionMunged at 01.0
license: BSD-3-Clause
license-file: LICENSE
maintainer: The GHC Developers <ghc-devs at haskell.org>
=====================================
libraries/ghci/GHCi/TH.hs
=====================================
@@ -1,6 +1,9 @@
{-# LANGUAGE ScopedTypeVariables, StandaloneDeriving, DeriveGeneric,
TupleSections, RecordWildCards, InstanceSigs, CPP #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
+{-# OPTIONS_GHC -Wno-warnings-deprecations #-}
+-- TODO We want to import GHC.Internal.Desugar instead of GHC.Desugar when we
+-- can require of the bootstrap compiler to have ghc-internal.
-- |
-- Running TH splices
@@ -109,7 +112,7 @@ import Data.IORef
import Data.Map (Map)
import qualified Data.Map as M
import Data.Maybe
-import GHC.Desugar
+import GHC.Desugar (AnnotationWrapper(..))
import qualified GHC.Internal.TH.Syntax as TH
import Unsafe.Coerce
=====================================
libraries/ghci/ghci.cabal.in
=====================================
@@ -85,6 +85,10 @@ library
rts,
array == 0.5.*,
base >= 4.8 && < 4.21,
+ -- ghc-internal == @ProjectVersionMunged at 01.*
+ -- TODO: Use GHC.Internal.Desugar from ghc-internal instead of ignoring
+ -- the deprecation warning of GHC.Desugar when we require ghc-internal
+ -- of the bootstrap compiler
ghc-prim >= 0.5.0 && < 0.12,
binary == 0.8.*,
bytestring >= 0.10 && < 0.13,
=====================================
utils/haddock/CHANGES.md
=====================================
@@ -3,6 +3,8 @@
* Add incremental mode to support rendering documentation one module at a time.
+ * Fix large margin on top of small headings
+
## Changes in 2.28.0
* `hi-haddock` is integrated, which means docstrings are no longer extracted
through typchecked module results. Instead, docstrings are taken from Haskell
=====================================
utils/haddock/haddock-api/resources/html/Linuwial.std-theme/linuwial.css
=====================================
@@ -295,10 +295,14 @@ pre, code, kbd, samp, tt, .src {
}
-* + h1, * + h2, * + h3, * + h4, * + h5, * + h6 {
+* + h1, * + h2, * + h3 {
margin-top: 2em;
}
+* + h4 , * + h5, * + h6 {
+ margin-top: 1em;
+}
+
h1 + h2, h2 + h3, h3 + h4, h4 + h5, h5 + h6 {
margin-top: inherit;
}
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/622081070d0496aa1d1159974ceeac77e6722bd8...abbac7ff38a518c8e15b06348b721e9dad8c9af0
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/622081070d0496aa1d1159974ceeac77e6722bd8...abbac7ff38a518c8e15b06348b721e9dad8c9af0
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240807/2b66f8ac/attachment-0001.html>
More information about the ghc-commits
mailing list