Cheng Shao pushed to branch wip/haddock-move-binary-instances at Glasgow Haskell Compiler / GHC
Commits:
-
0523deff
by Cheng Shao at 2025-06-19T02:12:57+00:00
3 changed files:
- compiler/GHC/Iface/Ext/Types.hs
- compiler/GHC/Utils/Binary.hs
- utils/haddock/haddock-api/src/Haddock/InterfaceFile.hs
Changes:
... | ... | @@ -98,10 +98,6 @@ data HieFile = HieFile |
98 | 98 | |
99 | 99 | type NameEntityInfo = M.Map Name (S.Set EntityInfo)
|
100 | 100 | |
101 | -instance Binary NameEntityInfo where
|
|
102 | - put_ bh m = put_ bh $ M.toList m
|
|
103 | - get bh = fmap M.fromList (get bh)
|
|
104 | - |
|
105 | 101 | instance Binary HieFile where
|
106 | 102 | put_ bh hf = do
|
107 | 103 | put_ bh $ hie_hs_file hf
|
... | ... | @@ -2131,6 +2131,13 @@ instance (Binary v) => Binary (IntMap v) where |
2131 | 2131 | put_ bh m = put_ bh (IntMap.toAscList m)
|
2132 | 2132 | get bh = IntMap.fromAscList <$> get bh
|
2133 | 2133 | |
2134 | +instance (Ord k, Binary k, Binary v) => Binary (Map k v) where
|
|
2135 | + put_ bh m = put_ bh $ Map.toList m
|
|
2136 | + -- Unfortunately, we can't use fromAscList, since k is often
|
|
2137 | + -- instantiated to Name which has a non-deterministic Ord instance
|
|
2138 | + -- that only compares the Uniques, and the Uniques are likely
|
|
2139 | + -- changed when deserializing!
|
|
2140 | + get bh = Map.fromList <$> get bh
|
|
2134 | 2141 | |
2135 | 2142 | {- Note [FingerprintWithValue]
|
2136 | 2143 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
... | ... | @@ -40,7 +40,6 @@ import Data.Coerce (coerce) |
40 | 40 | import Data.Function ((&))
|
41 | 41 | import Data.IORef
|
42 | 42 | import Data.Map (Map)
|
43 | -import qualified Data.Map as Map
|
|
44 | 43 | import Data.Version
|
45 | 44 | import Data.Word
|
46 | 45 | import GHC hiding (NoLink)
|
... | ... | @@ -319,10 +318,6 @@ data BinDictionary = BinDictionary |
319 | 318 | |
320 | 319 | -------------------------------------------------------------------------------
|
321 | 320 | |
322 | -instance (Ord k, Binary k, Binary v) => Binary (Map k v) where
|
|
323 | - put_ bh m = put_ bh (Map.toList m)
|
|
324 | - get bh = fmap (Map.fromList) (get bh)
|
|
325 | - |
|
326 | 321 | instance Binary PackageInfo where
|
327 | 322 | put_ bh PackageInfo{piPackageName, piPackageVersion} = do
|
328 | 323 | put_ bh (unPackageName piPackageName)
|