1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 00:12:29 +03:00

Trace out the module table for easy debug/dev of import resolution

This commit is contained in:
Timothy Clem 2018-04-03 15:44:57 -07:00
parent 0d29d38c50
commit edc00cff27
2 changed files with 5 additions and 2 deletions

View File

@ -15,7 +15,10 @@ data ModuleInfo = ModuleInfo { modulePath :: FilePath, moduleRoot :: FilePath }
deriving (Eq, Ord, Show)
data Module term = Module { moduleInfo :: ModuleInfo, moduleBody :: term }
deriving (Eq, Foldable, Functor, Ord, Show, Traversable)
deriving (Eq, Foldable, Functor, Ord, Traversable)
instance Show (Module term) where
showsPrec _ Module{..} = shows moduleInfo
-- | Construct a 'Module' for a 'Blob' and @term@, relative to some root 'FilePath'.

View File

@ -40,7 +40,7 @@ insert k v = ModuleTable . Map.insert k v . unModuleTable
-- | Construct a 'ModuleTable' from a list of 'Module's.
fromModules :: [Module term] -> ModuleTable [Module term]
fromModules = ModuleTable . Map.fromListWith (<>) . map toEntry
fromModules modules = let x = ModuleTable (Map.fromListWith (<>) (map toEntry modules)) in traceShow x x
where toEntry m = (modulePath (moduleInfo m), [m])
toPairs :: ModuleTable a -> [(ModulePath, a)]