diff --git a/semantic.cabal b/semantic.cabal index 95c75ab6f..ea9ae489f 100644 --- a/semantic.cabal +++ b/semantic.cabal @@ -42,6 +42,7 @@ library , Control.Abstract.Heap , Control.Abstract.Label , Control.Abstract.Matching + , Control.Abstract.ModuleTable , Control.Abstract.Roots , Control.Abstract.Value -- Control flow diff --git a/src/Control/Abstract.hs b/src/Control/Abstract.hs index e1cd2b5d0..6edd0594a 100644 --- a/src/Control/Abstract.hs +++ b/src/Control/Abstract.hs @@ -10,5 +10,6 @@ import Control.Abstract.Evaluator as X import Control.Abstract.Exports as X import Control.Abstract.Heap as X import Control.Abstract.Label as X +import Control.Abstract.ModuleTable as X import Control.Abstract.Roots as X import Control.Abstract.Value as X diff --git a/src/Control/Abstract/Evaluator.hs b/src/Control/Abstract/Evaluator.hs index 0b4083e4d..99cd37f52 100644 --- a/src/Control/Abstract/Evaluator.hs +++ b/src/Control/Abstract/Evaluator.hs @@ -1,12 +1,6 @@ {-# LANGUAGE GADTs, GeneralizedNewtypeDeriving, RankNTypes, ScopedTypeVariables, TypeFamilies, TypeOperators #-} module Control.Abstract.Evaluator ( Evaluator(..) - -- * State - , ModuleTable - -- * Module tables - , getModuleTable - , putModuleTable - , modifyModuleTable -- * Effects , EvalClosure(..) , evaluateClosureBody @@ -53,21 +47,6 @@ newtype Evaluator location term value effects a = Evaluator { runEvaluator :: Ef deriving instance Member NonDet effects => Alternative (Evaluator location term value effects) --- Module table - --- | Retrieve the table of evaluated modules. -getModuleTable :: Member (State (ModuleTable (Environment location value, value))) effects => Evaluator location term value effects (ModuleTable (Environment location value, value)) -getModuleTable = raise get - --- | Set the table of evaluated modules. -putModuleTable :: Member (State (ModuleTable (Environment location value, value))) effects => ModuleTable (Environment location value, value) -> Evaluator location term value effects () -putModuleTable = raise . put - --- | Update the evaluated module table. -modifyModuleTable :: Member (State (ModuleTable (Environment location value, value))) effects => (ModuleTable (Environment location value, value) -> ModuleTable (Environment location value, value)) -> Evaluator location term value effects () -modifyModuleTable = raise . modify' - - -- Effects -- | An effect to evaluate a closure’s body. diff --git a/src/Control/Abstract/ModuleTable.hs b/src/Control/Abstract/ModuleTable.hs new file mode 100644 index 000000000..b098e8aff --- /dev/null +++ b/src/Control/Abstract/ModuleTable.hs @@ -0,0 +1,23 @@ +module Control.Abstract.ModuleTable +( ModuleTable +, getModuleTable +, putModuleTable +, modifyModuleTable +) where + +import Control.Abstract.Evaluator +import Data.Abstract.Environment +import Data.Abstract.ModuleTable +import Prologue + +-- | Retrieve the table of evaluated modules. +getModuleTable :: Member (State (ModuleTable (Environment location value, value))) effects => Evaluator location term value effects (ModuleTable (Environment location value, value)) +getModuleTable = raise get + +-- | Set the table of evaluated modules. +putModuleTable :: Member (State (ModuleTable (Environment location value, value))) effects => ModuleTable (Environment location value, value) -> Evaluator location term value effects () +putModuleTable = raise . put + +-- | Update the evaluated module table. +modifyModuleTable :: Member (State (ModuleTable (Environment location value, value))) effects => (ModuleTable (Environment location value, value) -> ModuleTable (Environment location value, value)) -> Evaluator location term value effects () +modifyModuleTable = raise . modify'