mirror of
https://github.com/github/semantic.git
synced 2024-12-20 21:31:48 +03:00
Rephrase in terms of caching a result for a module.
This commit is contained in:
parent
534a261e16
commit
f1bf4ba019
@ -32,9 +32,9 @@ type EvaluatedModules location value = ModuleTable (Maybe (Environment location
|
|||||||
getModuleTable :: Member (State (EvaluatedModules location value)) effects => Evaluator location term value effects (EvaluatedModules location value)
|
getModuleTable :: Member (State (EvaluatedModules location value)) effects => Evaluator location term value effects (EvaluatedModules location value)
|
||||||
getModuleTable = raise get
|
getModuleTable = raise get
|
||||||
|
|
||||||
-- | Update the evaluated module table.
|
-- | Cache a result in the evaluated module table.
|
||||||
modifyModuleTable :: Member (State (EvaluatedModules location value)) effects => (EvaluatedModules location value -> EvaluatedModules location value) -> Evaluator location term value effects ()
|
cacheModule :: Member (State (EvaluatedModules location value)) effects => ModulePath -> Maybe (Environment location value, value) -> Evaluator location term value effects ()
|
||||||
modifyModuleTable = raise . modify'
|
cacheModule path result = raise (modify' (ModuleTable.insert path result))
|
||||||
|
|
||||||
|
|
||||||
-- | Retrieve the table of unevaluated modules.
|
-- | Retrieve the table of unevaluated modules.
|
||||||
@ -109,7 +109,7 @@ load name = askModuleTable >>= maybeM notFound . ModuleTable.lookup name >>= run
|
|||||||
v <- localLoadStack (loadStackPush (moduleInfo x)) (traceE ("load (evaluating): " <> show mPath) *> evaluateModule x)
|
v <- localLoadStack (loadStackPush (moduleInfo x)) (traceE ("load (evaluating): " <> show mPath) *> evaluateModule x)
|
||||||
traceE ("load done:" <> show mPath)
|
traceE ("load done:" <> show mPath)
|
||||||
env <- filterEnv <$> getExports <*> getEnv
|
env <- filterEnv <$> getExports <*> getEnv
|
||||||
modifyModuleTable (ModuleTable.insert name (Just (env, v)))
|
cacheModule name (Just (env, v))
|
||||||
pure (Just (env, v))
|
pure (Just (env, v))
|
||||||
|
|
||||||
-- TODO: If the set of exports is empty because no exports have been
|
-- TODO: If the set of exports is empty because no exports have been
|
||||||
|
Loading…
Reference in New Issue
Block a user