1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 22:31:36 +03:00

Add require function that uses a Linker effect

This commit is contained in:
joshvera 2018-02-22 16:30:58 -05:00
parent 159cfae2d6
commit d1bedfb793

View File

@ -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)