packages feed

inventory 0.1.0.1 → 0.1.0.2

raw patch · 3 files changed

+37/−10 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

README.md view
@@ -12,7 +12,9 @@ ## Using inventory  Install with `stack update && stack install inventory` or `cabal update &&-cabal install inventory`.+cabal install inventory`. The version used to compile `inventory` must be the+same as the version used to compile your project. For stack users, this means+you may have to `stack install` from within your project to use the right GHC.  Inventory uses `.hie` files to gather information about all haskell files in the project. Once you have generated `.hie` files for your project, execute@@ -80,5 +82,3 @@ - Standalone kind signatures are not yet included in definition counts. - Does not unfold type synonyms when comparing type signatures. - GHC versions other than 8.8, 8.10, and 9.0 are not currently supported.-- You may encounter errors if the version of GHC used to compile `inventory` is-  different from the version used to compile your project.
inventory.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: fee986bf906b9590bf18ee9a5c29116d193fe782a4027076edfdc92f4e418ce3+-- hash: 2c217de02982da803d30a671d986dea8bc36b776a638aafdd2b1599609a962f1  name:           inventory-version:        0.1.0.1+version:        0.1.0.2 synopsis:       Project statistics and definition analysis description:    Please see the README on GitHub at <https://github.com/aaronallen8455/inventory#readme> category:       Utility
src/HieFile.hs view
@@ -20,6 +20,7 @@ import           Data.Monoid import           System.Directory (canonicalizePath, doesDirectoryExist, doesFileExist, doesPathExist, listDirectory, withCurrentDirectory) import           System.Environment (lookupEnv)+import           System.Exit (exitFailure) import           System.FilePath (isExtensionOf)  import           DefCounts.ProcessHie@@ -57,8 +58,12 @@ getHieFiles = do   hieDir <- fromMaybe ".hie" <$> lookupEnv "HIE_DIR"   filePaths <- getHieFilesIn hieDir-    `onException` error "HIE file directory does not exist"-  when (null filePaths) . error $ "No HIE files found in dir: " <> hieDir+    `onException` do+      putStrLn ("HIE file directory does not exist: " <> show hieDir)+      exitFailure+  when (null filePaths) $ do+    putStrLn $ "No HIE files found in dir: " <> show hieDir+    exitFailure   hieFiles <- hieFilesFromPaths filePaths   let srcFileExists = doesPathExist . hie_hs_file   filterM srcFileExists hieFiles@@ -69,9 +74,16 @@ hieFilesFromPaths filePaths = do   nameCacheRef <- newIORef =<< mkNameCache   let updater = NCU $ atomicModifyIORef' nameCacheRef-  traverse (fmap hie_file_result . readHieFile updater)-           filePaths+  traverse (getHieFile updater) filePaths +getHieFile :: NameCacheUpdater -> FilePath -> IO HieFile+getHieFile ncUpdater filePath =+  handleHieVersionMismatch filePath . fmap hie_file_result+    =<< readHieFileWithVersion+          (\(v, _) -> v == hieVersion)+          ncUpdater+          filePath+ #else  hieFilesFromPaths :: [FilePath] -> IO [HieFile]@@ -81,9 +93,24 @@  getHieFile :: FilePath -> StateT NameCache IO HieFile getHieFile filePath = StateT $ \nameCache ->-  first hie_file_result <$> readHieFile nameCache filePath+  handleHieVersionMismatch filePath . fmap (first hie_file_result)+    =<< readHieFileWithVersion+          (\(v, _) -> v == hieVersion)+          nameCache+          filePath  #endif++handleHieVersionMismatch :: FilePath -> Either HieHeader a -> IO a+handleHieVersionMismatch path = either errMsg pure where+  errMsg (ver, _ghcVer) = do+    putStrLn $ unlines+      [ "Incompatible hie file: " <> path+      , "hie files must be generated with the same GHC version used to compile inventory"+      , "Inventory was compiled with GHC version " <> show hieVersion+      , "The hie files for this project were generated with version " <> show ver+      ]+    exitFailure  mkNameCache :: IO NameCache mkNameCache = do