packages feed

hi-file-parser 0.1.3.0 → 0.1.4.0

raw patch · 46 files changed

+76/−52 lines, 46 filesbinary-addedPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -6,11 +6,16 @@ and this project adheres to the
 [Haskell Package Versioning Policy](https://pvp.haskell.org/).
 
+## 0.1.4.0 - 2023-04-28
+
+* Add further support for GHC 9.4 (GHC 9.4.5 onward) and support for GHC 9.6.
+  See [#14](https://github.com/commercialhaskell/hi-file-parser/pull/14)
+
 ## 0.1.3.0 - 2022-08-12
 
 * Allow dependency on `mtl` >= 2.3. See
   [#6](https://github.com/commercialhaskell/hi-file-parser/pull/6)
-* Add support for GHC 9.4. See
+* Add support for GHC 9.4 (up to GHC 9.4.4). See
   [#7](https://github.com/commercialhaskell/hi-file-parser/pull/7)
 
 ## 0.1.2.0 - 2021-04-09
hi-file-parser.cabal view
@@ -1,11 +1,11 @@-cabal-version: 1.12+cabal-version: 1.12
 --- This file has been generated from package.yaml by hpack version 0.35.0.+-- This file has been generated from package.yaml by hpack version 0.35.2. -- -- see: https://github.com/sol/hpack  name:           hi-file-parser-version:        0.1.3.0+version:        0.1.4.0 synopsis:       Parser for GHC's hi files description:    Please see the README on Github at <https://github.com/commercialhaskell/hi-file-parser/blob/master/README.md> category:       Development@@ -19,26 +19,30 @@ extra-source-files:     README.md     ChangeLog.md-    test-files/iface/x64/ghc844/Main.hi-    test-files/iface/x64/ghc844/X.hi-    test-files/iface/x64/ghc822/Main.hi-    test-files/iface/x64/ghc822/X.hi-    test-files/iface/x64/ghc864/Main.hi-    test-files/iface/x64/ghc864/X.hi-    test-files/iface/x64/ghc884/Main.hi-    test-files/iface/x64/ghc884/X.hi-    test-files/iface/x64/ghc8104/Main.hi-    test-files/iface/x64/ghc8104/X.hi-    test-files/iface/x64/ghc901/Main.hi-    test-files/iface/x64/ghc901/X.hi-    test-files/iface/x64/ghc9023/Main.hi-    test-files/iface/x64/ghc9023/X.hi-    test-files/iface/x64/ghc9041/Main.hi-    test-files/iface/x64/ghc9041/X.hi-    test-files/iface/x32/ghc844/Main.hi-    test-files/iface/x32/ghc802/Main.hi     test-files/iface/x32/ghc7103/Main.hi-    test-files/iface/x32/ghc822/Main.hi+    test-files/iface/x32/ghc8002/Main.hi+    test-files/iface/x32/ghc8022/Main.hi+    test-files/iface/x32/ghc8044/Main.hi+    test-files/iface/x64/ghc8022/Main.hi+    test-files/iface/x64/ghc8022/X.hi+    test-files/iface/x64/ghc8044/Main.hi+    test-files/iface/x64/ghc8044/X.hi+    test-files/iface/x64/ghc8065/Main.hi+    test-files/iface/x64/ghc8065/X.hi+    test-files/iface/x64/ghc8084/Main.hi+    test-files/iface/x64/ghc8084/X.hi+    test-files/iface/x64/ghc8107/Main.hi+    test-files/iface/x64/ghc8107/X.hi+    test-files/iface/x64/ghc9002/Main.hi+    test-files/iface/x64/ghc9002/X.hi+    test-files/iface/x64/ghc9027/Main.hi+    test-files/iface/x64/ghc9027/X.hi+    test-files/iface/x64/ghc9044/Main.hi+    test-files/iface/x64/ghc9044/X.hi+    test-files/iface/x64/ghc9045/Main.hi+    test-files/iface/x64/ghc9045/X.hi+    test-files/iface/x64/ghc9061/Main.hi+    test-files/iface/x64/ghc9061/X.hi  source-repository head   type: git
src/HiFileParser.hs view
@@ -63,6 +63,7 @@   | V8101
   | V9001
   | V9041
+  | V9045
   deriving (Show,Eq,Ord,Enum)
   -- careful, the Ord matters!
 
@@ -205,6 +206,10 @@     traceGet ("Dictionary: " ++ show dict)
     return dict
 
+-- | Get a FastString
+--
+-- FastStrings are stored in a global FastString table and only the index (a
+-- Word32be) is stored at the expected position.
 getCachedBS :: Dictionary -> Get ByteString
 getCachedBS d = go =<< traceShow "Dict index:" getWord32be
   where
@@ -515,6 +520,8 @@     dusage <- traceShow "Usage:"        getUsage
     pure (Interface ddeps dusage)
   where
+    since v = when (version >= v)
+
     getModule = do
         idType <- traceShow "Unit type:" getWord8
         case idType of
@@ -566,40 +573,42 @@ 
     getUsage = withBlockPrefix $ List . catMaybes . unList <$> getList go
       where
+        -- this must follow the `Binary Usage` instance in GHC
+        -- (in GHC.Unit.Module.Deps, at least in GHC 9.4.5)
         go :: Get (Maybe Usage)
         go = do
             usageType <- traceShow "Usage type:" getWord8
             case usageType of
                 0 -> do
-                  void (traceShow "Module:" getModule)
-                  void getFP
-                  void getBool
+                  void (traceShow "Module:" getModule) -- usg_mod
+                  void getFP                           -- usg_mod_hash
+                  void getBool                         -- usg_safe
                   pure Nothing
 
                 1 -> do
-                    void (traceShow "Home module:" (getCachedBS d))
-                    void getFP
-                    void (getMaybe getFP)
-                    void (getList (getTuple (getWord8 *> getCachedBS d) getFP))
-                    void getBool
+                    void (traceShow "Home module:" (getCachedBS d)) -- usg_mod_name
+                    since V9045 $ void (getCachedBS d)              -- usg_unit_id
+                    void getFP                                      -- usg_mod_hash
+                    void (getMaybe getFP)                           -- usg_exports
+                    void (getList (getTuple (getWord8 *> getCachedBS d) getFP)) -- usg_entities
+                    void getBool                                    -- usg_safe
                     pure Nothing
 
                 2 -> do
-                  file_path  <- traceShow "File:" getString
-                  _file_hash <- traceShow "FP:" getFP'
-                  when (version >= V9041) $ do
-                    _file_label <- traceShow "File label:" (getMaybe getString)
-                    pure ()
+                  file_path  <- traceShow "File:" getString         -- usg_file_path
+                  void $ traceShow "FP:" getFP'                     -- usg_file_hash
+                  since V9041 $ void $ traceShow "File label:" (getMaybe getString)-- usg_file_label
                   pure (Just (Usage file_path))
 
                 3 -> do
-                  void getModule
-                  void getFP
+                  void getModule -- usg_mod
+                  void getFP     -- usg_mod_hash
                   pure Nothing
 
                 4 | version >= V9041 -> do -- UsageHomeModuleInterface
-                  _mod_name   <- void (getCachedBS d)
-                  _iface_hash <- void getFP
+                  void (getCachedBS d)                -- usg_mod_name
+                  since V9045 $ void (getCachedBS d)  -- usg_unit_id
+                  void getFP                          -- usg_iface_hash
                   pure Nothing
 
                 _ -> fail $ "Invalid usageType: " <> show usageType
@@ -641,6 +650,7 @@     traceGet ("Version: " ++ version)
 
     let !ifaceVersion
+          | version >= "9045" = V9045
           | version >= "9041" = V9041
           | version >= "9001" = V9001
           | version >= "8101" = V8101
@@ -675,6 +685,7 @@     void getPtr
 
     case ifaceVersion of
+      V9045 -> getInterfaceRecent ifaceVersion dict
       V9041 -> getInterfaceRecent ifaceVersion dict
       V9001 -> getInterfaceRecent ifaceVersion dict
       V8101 -> getInterfaceRecent ifaceVersion dict
+ test-files/iface/x32/ghc8002/Main.hi view

binary file changed (absent → 1067 bytes)

− test-files/iface/x32/ghc802/Main.hi

binary file changed (1067 → absent bytes)

+ test-files/iface/x32/ghc8022/Main.hi view

binary file changed (absent → 1217 bytes)

+ test-files/iface/x32/ghc8044/Main.hi view

binary file changed (absent → 1168 bytes)

− test-files/iface/x32/ghc822/Main.hi

binary file changed (1217 → absent bytes)

− test-files/iface/x32/ghc844/Main.hi

binary file changed (1168 → absent bytes)

+ test-files/iface/x64/ghc8022/Main.hi view

binary file changed (absent → 2178 bytes)

+ test-files/iface/x64/ghc8022/X.hi view

binary file changed (absent → 866 bytes)

+ test-files/iface/x64/ghc8044/Main.hi view

binary file changed (absent → 2196 bytes)

+ test-files/iface/x64/ghc8044/X.hi view

binary file changed (absent → 817 bytes)

+ test-files/iface/x64/ghc8065/Main.hi view

binary file changed (absent → 1901 bytes)

+ test-files/iface/x64/ghc8065/X.hi view

binary file changed (absent → 844 bytes)

+ test-files/iface/x64/ghc8084/Main.hi view

binary file changed (absent → 1974 bytes)

+ test-files/iface/x64/ghc8084/X.hi view

binary file changed (absent → 849 bytes)

− test-files/iface/x64/ghc8104/Main.hi

binary file changed (1266 → absent bytes)

− test-files/iface/x64/ghc8104/X.hi

binary file changed (633 → absent bytes)

+ test-files/iface/x64/ghc8107/Main.hi view

binary file changed (absent → 1267 bytes)

+ test-files/iface/x64/ghc8107/X.hi view

binary file changed (absent → 634 bytes)

− test-files/iface/x64/ghc822/Main.hi

binary file changed (2178 → absent bytes)

− test-files/iface/x64/ghc822/X.hi

binary file changed (866 → absent bytes)

− test-files/iface/x64/ghc844/Main.hi

binary file changed (2196 → absent bytes)

− test-files/iface/x64/ghc844/X.hi

binary file changed (817 → absent bytes)

− test-files/iface/x64/ghc864/Main.hi

binary file changed (2223 → absent bytes)

− test-files/iface/x64/ghc864/X.hi

binary file changed (844 → absent bytes)

− test-files/iface/x64/ghc884/Main.hi

binary file changed (1974 → absent bytes)

− test-files/iface/x64/ghc884/X.hi

binary file changed (849 → absent bytes)

+ test-files/iface/x64/ghc9002/Main.hi view

binary file changed (absent → 1319 bytes)

+ test-files/iface/x64/ghc9002/X.hi view

binary file changed (absent → 605 bytes)

− test-files/iface/x64/ghc901/Main.hi

binary file changed (1308 → absent bytes)

− test-files/iface/x64/ghc901/X.hi

binary file changed (610 → absent bytes)

− test-files/iface/x64/ghc9023/Main.hi

binary file changed (1326 → absent bytes)

− test-files/iface/x64/ghc9023/X.hi

binary file changed (625 → absent bytes)

+ test-files/iface/x64/ghc9027/Main.hi view

binary file changed (absent → 1341 bytes)

+ test-files/iface/x64/ghc9027/X.hi view

binary file changed (absent → 628 bytes)

− test-files/iface/x64/ghc9041/Main.hi

binary file changed (2478 → absent bytes)

− test-files/iface/x64/ghc9041/X.hi

binary file changed (639 → absent bytes)

+ test-files/iface/x64/ghc9044/Main.hi view

binary file changed (absent → 2654 bytes)

+ test-files/iface/x64/ghc9044/X.hi view

binary file changed (absent → 635 bytes)

+ test-files/iface/x64/ghc9045/Main.hi view

binary file changed (absent → 2470 bytes)

+ test-files/iface/x64/ghc9045/X.hi view

binary file changed (absent → 638 bytes)

+ test-files/iface/x64/ghc9061/Main.hi view

binary file changed (absent → 2462 bytes)

+ test-files/iface/x64/ghc9061/X.hi view

binary file changed (absent → 638 bytes)

test/HiFileParserSpec.hs view
@@ -14,24 +14,28 @@ type Usage = String
 type Module = ByteString
 
+-- | GHC x.y.z is represented as \"ghcxyyz\" where yy is padded with zeros.
 versions32 :: [Version]
 versions32 =
-  [ "ghc7103"
-  , "ghc802"
-  , "ghc822"
-  , "ghc844"
+  [ "ghc7103"  -- Last in GHC 7.10 series, using GHC 7.8.1 format
+  , "ghc8002"  -- Last in GHC 8.0 series, using GHC 8.0.1 format
+  , "ghc8022"  -- Last in GHC 8.2 series, using GHC 8.2.1 format
+  , "ghc8044"  -- Last in GHC 8.4 series, using GHC 8.4.1 format
   ]
 
+-- | GHC x.y.z is represented as \"ghcxyyz\" where yy is padded with zeros.
 versions64 :: [Version]
 versions64 =
-  [ "ghc822"
-  , "ghc844"
-  , "ghc864"
-  , "ghc884"
-  , "ghc8104"
-  , "ghc901"
-  , "ghc9023"
-  , "ghc9041"
+  [ "ghc8022"  -- Last in GHC 8.2 series, using GHC 8.0.1 format
+  , "ghc8044"  -- Last in GHC 8.4 series, using GHC 8.4.1 format
+  , "ghc8065"  -- Last in GHC 8.6 series, using GHC 8.6.1 format
+  , "ghc8084"  -- Last in GHC 8.8 series, using GHC 8.6.1 format
+  , "ghc8107"  -- Last in GHC 8.10 series, using GHC 8.10.1 format
+  , "ghc9002"  -- Last in GHC 9.0 series, using GHC 9.0.1 format
+  , "ghc9027"  -- Last in GHC 9.2 series, using GHC 9.0.1 format
+  , "ghc9044"  -- Last using GHC 9.4.1 format
+  , "ghc9045"  -- First using GHC 9.4.5 format; last in GHC 9.4 series
+  , "ghc9061"  -- Last in GHC 9.6 series, using GHC 9.4.5 format
   ]
 
 spec :: Spec