mirror of
https://github.com/github/semantic.git
synced 2024-12-19 12:51:52 +03:00
Define a withModules function running an action with a module table constructed from a list of modules.
This commit is contained in:
parent
9819f2c29b
commit
b08969b44c
@ -3,6 +3,7 @@
|
||||
module Control.Abstract.Analysis
|
||||
( MonadAnalysis(..)
|
||||
, evaluateTerm
|
||||
, withModules
|
||||
, withModulesForBlobs
|
||||
, require
|
||||
, load
|
||||
@ -60,6 +61,10 @@ evaluateTerm :: MonadAnalysis term value m => term -> m value
|
||||
evaluateTerm = foldSubterms analyzeTerm
|
||||
|
||||
|
||||
withModules :: MonadAnalysis term value m => [Module term] -> m a -> m a
|
||||
withModules modules = localModuleTable (const moduleTable)
|
||||
where moduleTable = ModuleTable (Map.fromListWith (<>) (map ((,) . moduleName <*> pure) modules))
|
||||
|
||||
-- | Run an action with the passed ('Blob', @term@) pairs available for imports.
|
||||
withModulesForBlobs :: MonadAnalysis term value m => Blob -> [(Blob, term)] -> m a -> m a
|
||||
withModulesForBlobs blob pairs = localModuleTable (const moduleTable)
|
||||
|
Loading…
Reference in New Issue
Block a user