diff --git a/src/Control/Abstract/Analysis.hs b/src/Control/Abstract/Analysis.hs index 2550c09e1..c5f2cc422 100644 --- a/src/Control/Abstract/Analysis.hs +++ b/src/Control/Abstract/Analysis.hs @@ -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)