From 32609034a0241808b7dfe9e2dd711d41efe0a670 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Thu, 1 Mar 2018 15:08:58 -0500 Subject: [PATCH] Abstract load/require over the term evaluator. --- src/Analysis/Abstract/Evaluating.hs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Analysis/Abstract/Evaluating.hs b/src/Analysis/Abstract/Evaluating.hs index 35ebba6c3..581b815df 100644 --- a/src/Analysis/Abstract/Evaluating.hs +++ b/src/Analysis/Abstract/Evaluating.hs @@ -33,12 +33,11 @@ type Evaluating t v -- -- Looks up the term's name in the cache of evaluated modules first, returns a value if found, otherwise loads/evaluates the module. require :: ( AbstractValue v - , Evaluatable (Base term) , FreeVariables term , MonadAddressable (LocationFor v) v m + , MonadAnalysis term v m , MonadEvaluator term v m , MonadFunction term v m - , Recursive term , Semigroup (Cell (LocationFor v) v) ) => term @@ -50,12 +49,11 @@ require term = getModuleTable >>= maybe (load term) pure . linkerLookup name -- -- Always loads/evaluates. load :: ( AbstractValue v - , Evaluatable (Base term) , FreeVariables term , MonadAddressable (LocationFor v) v m + , MonadAnalysis term v m , MonadFunction term v m , MonadEvaluator term v m - , Recursive term , Semigroup (Cell (LocationFor v) v) ) => term @@ -64,7 +62,7 @@ load term = askModuleTable >>= maybe notFound evalAndCache . linkerLookup name where name = moduleName term notFound = fail ("cannot find " <> show name) evalAndCache e = do - v <- foldSubterms eval e + v <- evaluateTerm e modifyModuleTable (linkerInsert name v) pure v