diff --git a/src/Data/Abstract/Eval3.hs b/src/Data/Abstract/Eval3.hs index 8bb2f44d4..be852c3eb 100644 --- a/src/Data/Abstract/Eval3.hs +++ b/src/Data/Abstract/Eval3.hs @@ -4,6 +4,8 @@ module Data.Abstract.Eval3 ( Evaluatable(..) , EnvironmentFor , step +, require +, Linker , MonadGC(..) , MonadFail(..) , Recursive(..) @@ -19,6 +21,8 @@ import Control.Monad.Effect.Fail import Data.Abstract.Environment import Data.Abstract.FreeVariables import Data.Abstract.Value +import Data.Abstract.Linker +import Data.Semigroup import Data.Functor.Classes import Data.Proxy import Data.Term @@ -29,6 +33,11 @@ import Data.Union (Apply) import qualified Data.Union as U +require :: Members '[Fail, Reader (Linker v)] es => FilePath -> Eff es v +require name = do + linker <- ask + maybe (fail ("cannot find " <> show name)) pure (linkerLookup name linker) + -- a local and global environment binding variable names to addresses. -- class EvalEnv v m where -- askEnv :: m (Environment (LocationFor v) v)