[Git][ghc/ghc][wip/mp/ghc-9.10.1-determinism] determinism: Use a stable sort in WithHsDocIdentifiers binary instance
Matthew Pickering pushed to branch wip/mp/ghc-9.10.1-determinism at Glasgow Haskell Compiler / GHC Commits: 06ea36f3 by Matthew Pickering at 2026-02-02T17:28:42+00:00 determinism: Use a stable sort in WithHsDocIdentifiers binary instance `WithHsDocIdentifiers` is defined as ``` 71 data WithHsDocIdentifiers a pass = WithHsDocIdentifiers 72 { hsDocString :: !a 73 , hsDocIdentifiers :: ![Located (IdP pass)] 74 } ``` This list of names is populated from `rnHsDocIdentifiers`, which calls `lookupGRE`, which calls `lookupOccEnv_AllNameSpaces`, which calls `nonDetEltsUFM` and returns the results in an order depending on uniques. Sorting the list with a stable sort before returning the interface makes the output deterministic and follows the approach taken by other fields in `Docs`. Fixes #26858 - - - - - 1 changed file: - compiler/GHC/Hs/Doc.hs Changes: ===================================== compiler/GHC/Hs/Doc.hs ===================================== @@ -50,6 +50,7 @@ import qualified GHC.Utils.Outputable as O import GHC.Hs.Extension import GHC.Types.Unique.Map import Data.List (sortBy) +import Data.Function import GHC.Hs.DocString @@ -88,7 +89,7 @@ instance Outputable a => Outputable (WithHsDocIdentifiers a pass) where instance Binary a => Binary (WithHsDocIdentifiers a GhcRn) where put_ bh (WithHsDocIdentifiers s ids) = do put_ bh s - put_ bh $ BinLocated <$> ids + put_ bh $ BinLocated <$> (sortBy (stableNameCmp `on` getName) ids) get bh = liftA2 WithHsDocIdentifiers (get bh) (fmap unBinLocated <$> get bh) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/06ea36f3018cf094c3bbbc8bbb6772c0... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/06ea36f3018cf094c3bbbc8bbb6772c0... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Matthew Pickering (@mpickering)