[Git][ghc/ghc][wip/romes/25104] hi: Stable sort avails

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Thu Aug 1 12:42:07 UTC 2024



Rodrigo Mesquita pushed to branch wip/romes/25104 at Glasgow Haskell Compiler / GHC


Commits:
a91b11f4 by Rodrigo Mesquita at 2024-08-01T13:41:54+01:00
hi: Stable sort avails

Sorting the Avails in DocStructures is required to produce fully
deterministic interface files in presence of re-exported modules.

Fixes #25104

- - - - -


2 changed files:

- compiler/GHC/Hs/Doc.hs
- testsuite/tests/showIface/HaddockIssue849.stdout


Changes:

=====================================
compiler/GHC/Hs/Doc.hs
=====================================
@@ -133,6 +133,9 @@ data DocStructureItem
                             -- > module M (module X) where
                             -- > import R0 as X
                             -- > import R1 as X
+                            --
+                            -- Invariant: This list must be sorted to guarantee
+                            -- interface file determinism.
       !Avails
 
 instance Binary DocStructureItem where
@@ -153,7 +156,7 @@ instance Binary DocStructureItem where
     DsiModExport mod_names avails -> do
       putByte bh 4
       put_ bh mod_names
-      put_ bh avails
+      put_ bh (sortBy stableAvailCmp avails)
 
   get bh = do
     tag <- getByte bh


=====================================
testsuite/tests/showIface/HaddockIssue849.stdout
=====================================
@@ -11,12 +11,12 @@ docs:
          re-exported module(s): [Data.Functor.Identity]
            []
          re-exported module(s): [Data.Maybe]
-           [GHC.Internal.Maybe.Maybe{GHC.Internal.Maybe.Maybe,
-                                     GHC.Internal.Maybe.Nothing, GHC.Internal.Maybe.Just},
-            GHC.Internal.Data.Maybe.maybe]
+           [GHC.Internal.Data.Maybe.maybe,
+            GHC.Internal.Maybe.Maybe{GHC.Internal.Maybe.Maybe,
+                                     GHC.Internal.Maybe.Nothing, GHC.Internal.Maybe.Just}]
          re-exported module(s): [Data.Tuple]
-           [GHC.Internal.Data.Tuple.swap, GHC.Internal.Data.Tuple.curry,
-            GHC.Internal.Data.Tuple.fst, GHC.Internal.Data.Tuple.snd,
+           [GHC.Internal.Data.Tuple.curry, GHC.Internal.Data.Tuple.fst,
+            GHC.Internal.Data.Tuple.snd, GHC.Internal.Data.Tuple.swap,
             GHC.Internal.Data.Tuple.uncurry]
        named chunks:
        haddock options:



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a91b11f459ddedfeaee1fa657020306e19e4030c

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a91b11f459ddedfeaee1fa657020306e19e4030c
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/20240801/466306f9/attachment-0001.html>


More information about the ghc-commits mailing list