calligraphy 0.1.3 → 0.1.4
raw patch · 4 files changed
+50/−23 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Calligraphy.Compat.GHC: [nodeInfo] :: HieAST a -> NodeInfo a
+ Calligraphy.Compat.GHC: EvidenceVarBind :: EvVarSource -> Scope -> Maybe Span -> ContextInfo
+ Calligraphy.Compat.GHC: EvidenceVarUse :: ContextInfo
+ Calligraphy.Compat.GHC: [sourcedNodeInfo] :: HieAST a -> SourcedNodeInfo a
+ Calligraphy.Compat.Lib: getHieFiles :: [FilePath] -> IO [HieFile]
- Calligraphy.Compat.GHC: HFunTy :: a -> a -> HieType a
+ Calligraphy.Compat.GHC: HFunTy :: a -> a -> a -> HieType a
- Calligraphy.Compat.GHC: HieASTs :: Map FastString (HieAST a) -> HieASTs a
+ Calligraphy.Compat.GHC: HieASTs :: Map HiePath (HieAST a) -> HieASTs a
- Calligraphy.Compat.GHC: Node :: NodeInfo a -> Span -> [HieAST a] -> HieAST a
+ Calligraphy.Compat.GHC: Node :: SourcedNodeInfo a -> Span -> [HieAST a] -> HieAST a
- Calligraphy.Compat.GHC: NodeInfo :: Set (FastString, FastString) -> [a] -> NodeIdentifiers a -> NodeInfo a
+ Calligraphy.Compat.GHC: NodeInfo :: Set NodeAnnotation -> [a] -> NodeIdentifiers a -> NodeInfo a
- Calligraphy.Compat.GHC: [getAsts] :: HieASTs a -> Map FastString (HieAST a)
+ Calligraphy.Compat.GHC: [getAsts] :: HieASTs a -> Map HiePath (HieAST a)
- Calligraphy.Compat.GHC: [nodeAnnotations] :: NodeInfo a -> Set (FastString, FastString)
+ Calligraphy.Compat.GHC: [nodeAnnotations] :: NodeInfo a -> Set NodeAnnotation
- Calligraphy.Compat.GHC: moduleName :: Module -> ModuleName
+ Calligraphy.Compat.GHC: moduleName :: GenModule unit -> ModuleName
Files
- CHANGELOG.md +4/−0
- calligraphy.cabal +3/−3
- src/Calligraphy/Compat/Lib.hs +41/−1
- src/Calligraphy/Phases/Search.hs +2/−19
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Changelog +## 0.1.4+### [Added]+- [#16] [#17] GHC 9.4 support+ ## 0.1.3 ### [Changed]
calligraphy.cabal view
@@ -1,13 +1,13 @@ cabal-version: 2.4 name: calligraphy-version: 0.1.3+version: 0.1.4 license: BSD-3-Clause build-type: Simple license-file: LICENSE author: Jonas Carpay maintainer: Jonas Carpay <jonascarpay@gmail.com> copyright: 2022 Jonas Carpay-tested-with: GHC ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.2+tested-with: GHC ==8.8.4 || ==8.10.7 || ==9.0.2 || ==9.2.7 || ==9.4.4 extra-doc-files: CHANGELOG.md README.md@@ -16,7 +16,7 @@ description: Calligraphy is a Haskell call graph/source code visualizer. It works directly on GHC-generated HIE files, giving us features that would otherwise be tricky, like type information and support for generated files.- Calligraphy has been tested with all versions of GHC that can produce HIE files (i.e. GHC 8.8, 8.10, 9.0, and 9.2.)+ Calligraphy has been tested with all versions of GHC that can produce HIE files (i.e. GHC 8.8 through 9.4.) See the project's github page for more information. homepage: https://github.com/jonascarpay/calligraphy#readme
src/Calligraphy/Compat/Lib.hs view
@@ -14,12 +14,15 @@ showAnns, mergeSpans, isPointSpan,+ getHieFiles, ) where +import qualified Calligraphy.Compat.GHC as GHC import Calligraphy.Util.Lens import Data.IORef import qualified Data.Set as Set+import Control.Monad #if MIN_VERSION_ghc(9,0,0) import GHC.Iface.Ext.Binary@@ -35,11 +38,48 @@ import SrcLoc #endif +getHieFiles :: [FilePath] -> IO [HieFile]+#if MIN_VERSION_ghc(9,4,0)++getHieFiles filePaths = do+ ref <- newIORef =<< GHC.initNameCache 'z' []+ forM filePaths (readHieFileWithWarning ref)++#else++getHieFiles filePaths = do+ uniqSupply <- GHC.mkSplitUniqSupply 'z'+ ref <- newIORef (GHC.initNameCache uniqSupply [])+ forM filePaths (readHieFileWithWarning ref)++#endif++readHieFileWithWarning :: IORef GHC.NameCache -> FilePath -> IO GHC.HieFile+readHieFileWithWarning ref path = do+ GHC.HieFileResult fileHieVersion fileGHCVersion hie <- readHieFileCompat ref path+ when (GHC.hieVersion /= fileHieVersion) $ do+ putStrLn $ "WARNING: version mismatch in " <> path+ putStrLn $ " The hie files in this project were generated with GHC version: " <> show fileGHCVersion+ putStrLn $ " This version of calligraphy was compiled with GHC version: " <> show GHC.hieVersion+ putStrLn " Optimistically continuing anyway..."+ pure hie+ {-# INLINE sourceInfo #-} sourceInfo :: Traversal' (HieAST a) (NodeInfo a) showContextInfo :: ContextInfo -> String readHieFileCompat :: IORef NameCache -> FilePath -> IO HieFileResult-#if MIN_VERSION_ghc(9,0,0)++#if MIN_VERSION_ghc(9,4,0)++sourceInfo f (Node (SourcedNodeInfo inf) sp children) = (\inf' -> Node (SourcedNodeInfo inf') sp children) <$> Map.alterF (maybe (pure Nothing) (fmap Just . f)) SourceInfo inf++showContextInfo = showSDocUnsafe . ppr++readHieFileCompat ref path = do+ nameCache <- readIORef ref+ readHieFile nameCache path++#elif MIN_VERSION_ghc(9,0,0) sourceInfo f (Node (SourcedNodeInfo inf) sp children) = (\inf' -> Node (SourcedNodeInfo inf') sp children) <$> Map.alterF (maybe (pure Nothing) (fmap Just . f)) SourceInfo inf
src/Calligraphy/Phases/Search.hs view
@@ -8,10 +8,8 @@ where import qualified Calligraphy.Compat.GHC as GHC-import Calligraphy.Compat.Lib (readHieFileCompat)+import Calligraphy.Compat.Lib import Control.Applicative-import Control.Monad.State-import Data.IORef import Data.List (isPrefixOf) import Data.List.NonEmpty (NonEmpty (..), nonEmpty, toList) import Options.Applicative hiding (str)@@ -20,12 +18,7 @@ searchFiles :: SearchConfig -> IO [GHC.HieFile] searchFiles SearchConfig {searchDotPaths, searchRoots, includePatterns, excludePatterns} = do- hieFilePaths <- searchHieFilePaths-- hieFiles <- do- uniqSupply <- GHC.mkSplitUniqSupply 'z'- ref <- newIORef (GHC.initNameCache uniqSupply [])- forM hieFilePaths (readHieFileWithWarning ref)+ hieFiles <- getHieFiles =<< searchHieFilePaths pure $ flip filter hieFiles $ \file ->@@ -50,16 +43,6 @@ contents <- (if searchDotPaths then id else filter (not . isPrefixOf ".")) <$> listDirectory path foldMap (go . (path </>)) contents else pure []--readHieFileWithWarning :: IORef GHC.NameCache -> FilePath -> IO GHC.HieFile-readHieFileWithWarning ref path = do- GHC.HieFileResult fileHieVersion fileGHCVersion hie <- readHieFileCompat ref path- when (GHC.hieVersion /= fileHieVersion) $ do- putStrLn $ "WARNING: version mismatch in " <> path- putStrLn $ " The hie files in this project were generated with GHC version: " <> show fileGHCVersion- putStrLn $ " This version of calligraphy was compiled with GHC version: " <> show GHC.hieVersion- putStrLn $ " Optimistically continuing anyway..."- pure hie data SearchConfig = SearchConfig { includePatterns :: Maybe (NonEmpty Pattern),