1
1
mirror of https://github.com/github/semantic.git synced 2025-01-08 08:30:27 +03:00

Define evaluateModules in terms of evaluatePackage.

This commit is contained in:
Rob Rix 2018-03-30 19:05:32 -04:00
parent 52fa4c9c0f
commit 4e3c607c37
2 changed files with 8 additions and 6 deletions

View File

@ -26,7 +26,7 @@ import Data.Abstract.FreeVariables as X
import Data.Abstract.Module import Data.Abstract.Module
import Data.Abstract.ModuleTable as ModuleTable import Data.Abstract.ModuleTable as ModuleTable
import Data.Abstract.Origin (SomeOrigin, packageOrigin) import Data.Abstract.Origin (SomeOrigin, packageOrigin)
import Data.Abstract.Package import Data.Abstract.Package as Package
import Data.Semigroup.App import Data.Semigroup.App
import Data.Semigroup.Foldable import Data.Semigroup.Foldable
import Data.Semigroup.Reducer hiding (unit) import Data.Semigroup.Reducer hiding (unit)
@ -181,11 +181,13 @@ withModules :: MonadEvaluatable location term value m
withModules = localModuleTable . const . ModuleTable.fromModules withModules = localModuleTable . const . ModuleTable.fromModules
-- | Evaluate with a list of modules in scope, taking the head module as the entry point. -- | Evaluate with a list of modules in scope, taking the head module as the entry point.
evaluateModules :: MonadEvaluatable location term value m evaluateModules :: ( Effectful m
, Member (Reader (SomeOrigin term)) effects
, MonadEvaluatable location term value (m effects)
)
=> [Module term] => [Module term]
-> m value -> m effects [value]
evaluateModules [] = fail "evaluateModules: empty list" evaluateModules = evaluatePackage . Package.fromModules
evaluateModules (m:ms) = withModules ms (evaluateModule m)
evaluatePackage :: ( Effectful m evaluatePackage :: ( Effectful m
, Member (Reader (SomeOrigin term)) effects , Member (Reader (SomeOrigin term)) effects

View File

@ -130,7 +130,7 @@ evaluateFiles :: forall term effects
) )
=> Parser term => Parser term
-> [FilePath] -> [FilePath]
-> IO (Final effects (Value Precise)) -> IO (Final effects [Value Precise])
evaluateFiles parser paths = runAnalysis @(Evaluating Precise term (Value Precise)) . evaluateModules <$> parseFiles parser paths evaluateFiles parser paths = runAnalysis @(Evaluating Precise term (Value Precise)) . evaluateModules <$> parseFiles parser paths
-- | Evaluate terms and an entry point to a value with a given prelude. -- | Evaluate terms and an entry point to a value with a given prelude.