From 5d6c57312e0959b0788b4273acc681fa04b473c6 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Mon, 2 Apr 2018 17:30:04 -0400 Subject: [PATCH] Split the evaluation of a package body out into a new function. --- src/Data/Abstract/Evaluatable.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Data/Abstract/Evaluatable.hs b/src/Data/Abstract/Evaluatable.hs index b5425268f..ec3389960 100644 --- a/src/Data/Abstract/Evaluatable.hs +++ b/src/Data/Abstract/Evaluatable.hs @@ -186,8 +186,13 @@ evaluatePackage :: ( Effectful m ) => Package term -> m effects [value] -evaluatePackage p = pushOrigin (packageOrigin p) (localModuleTable (<> packageModules (packageBody p)) - (traverse evaluateEntryPoint (ModuleTable.toPairs (packageEntryPoints (packageBody p))))) +evaluatePackage p = pushOrigin (packageOrigin p) (evaluatePackageBody (packageBody p)) + +evaluatePackageBody :: MonadEvaluatable location term value m + => PackageBody term + -> m [value] +evaluatePackageBody body = localModuleTable (<> packageModules body) + (traverse evaluateEntryPoint (ModuleTable.toPairs (packageEntryPoints body))) where evaluateEntryPoint (m, sym) = do (_, v) <- require m maybe (pure v) ((`call` []) <=< variable) sym