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

The module table holds terms, not evaluators.

This commit is contained in:
Rob Rix 2018-02-28 14:01:40 -05:00
parent f99972622a
commit 965053dba1

View File

@ -12,76 +12,76 @@ import Data.Abstract.Linker
import Data.Abstract.Value
import Prelude hiding (fail)
getGlobalEnv :: Evaluator effects value (EnvironmentFor value)
getGlobalEnv :: Evaluator effects term value (EnvironmentFor value)
getGlobalEnv = Evaluator get
modifyGlobalEnv :: (EnvironmentFor value -> EnvironmentFor value) -> Evaluator effects value ()
modifyGlobalEnv :: (EnvironmentFor value -> EnvironmentFor value) -> Evaluator effects term value ()
modifyGlobalEnv f = Evaluator (modify f)
askLocalEnv :: Evaluator effects value (EnvironmentFor value)
askLocalEnv :: Evaluator effects term value (EnvironmentFor value)
askLocalEnv = Evaluator ask
localEnv :: (EnvironmentFor value -> EnvironmentFor value) -> Evaluator effects value a -> Evaluator effects value a
localEnv :: (EnvironmentFor value -> EnvironmentFor value) -> Evaluator effects term value a -> Evaluator effects term value a
localEnv f a = Evaluator (local f (runEvaluator a))
getStore :: Evaluator effects value (StoreFor value)
getStore :: Evaluator effects term value (StoreFor value)
getStore = Evaluator get
modifyStore :: (StoreFor value -> StoreFor value) -> Evaluator effects value ()
modifyStore :: (StoreFor value -> StoreFor value) -> Evaluator effects term value ()
modifyStore f = Evaluator (modify f)
getModuleTable :: Evaluator effects value (Linker value)
getModuleTable :: Evaluator effects term value (Linker value)
getModuleTable = Evaluator get
modifyModuleTable :: (Linker value -> Linker value) -> Evaluator effects value ()
modifyModuleTable :: (Linker value -> Linker value) -> Evaluator effects term value ()
modifyModuleTable f = Evaluator (modify f)
askModuleEvaluatorTable :: Evaluator effects value (Linker (Evaluator effects value value))
askModuleEvaluatorTable = Evaluator ask
askModuleTable :: Evaluator effects term value (Linker term)
askModuleTable = Evaluator ask
localModuleEvaluatorTable :: (Linker (Evaluator effects value value) -> Linker (Evaluator effects value value)) -> Evaluator effects value a -> Evaluator effects value a
localModuleEvaluatorTable f a = Evaluator (local f (runEvaluator a))
localModuleTable :: (Linker term -> Linker term) -> Evaluator effects term value a -> Evaluator effects term value a
localModuleTable f a = Evaluator (local f (runEvaluator a))
data Evaluator effects value a
data Evaluator effects term value a
= Evaluator
{ runEvaluator :: Members '[ Fail
, Reader (EnvironmentFor value)
, State (EnvironmentFor value)
, State (StoreFor value)
, Reader (Linker (Evaluator effects value value))
, Reader (Linker term)
, State (Linker value)
] effects
=> Eff effects a
}
instance Functor (Evaluator effects value) where
instance Functor (Evaluator effects term value) where
fmap f (Evaluator run) = Evaluator (fmap f run)
instance Applicative (Evaluator effects value) where
instance Applicative (Evaluator effects term value) where
pure = Evaluator . pure
Evaluator runF <*> Evaluator runA = Evaluator (runF <*> runA)
instance Member NonDetEff effects => Alternative (Evaluator effects value) where
instance Member NonDetEff effects => Alternative (Evaluator effects term value) where
empty = Evaluator empty
Evaluator runA <|> Evaluator runB = Evaluator (runA <|> runB)
instance Monad (Evaluator effects value) where
instance Monad (Evaluator effects term value) where
return = pure
Evaluator runA >>= f = Evaluator (runA >>= runEvaluator . f)
instance MonadFail (Evaluator effects value) where
instance MonadFail (Evaluator effects term value) where
fail s = Evaluator (fail s)
instance Member Fresh effects => MonadFresh (Evaluator effects value) where
instance Member Fresh effects => MonadFresh (Evaluator effects term value) where
fresh = Evaluator fresh
reset t = Evaluator (reset t)