1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 10:15:55 +03:00

We only need one handler.

This commit is contained in:
Rob Rix 2018-05-30 15:33:56 -04:00
parent a6025262c5
commit bf35d9db79

View File

@ -10,8 +10,6 @@ module Control.Abstract.Environment
, locally
, close
, Env(..)
, runEnv
, reinterpretEnv
, runEnvState
, EnvironmentError(..)
, freeVariableError
@ -82,21 +80,10 @@ handleEnv = \case
GetEnv -> get
Export name alias addr -> modify (Exports.insert name alias addr)
runEnv :: ( Member (State (Environment address)) effects
, Member (State (Exports address)) effects
)
=> Evaluator address value (Env address ': effects) a
-> Evaluator address value effects a
runEnv = interpret handleEnv
reinterpretEnv :: Evaluator address value (Env address ': effects) a
-> Evaluator address value (State (Environment address) ': State (Exports address) ': effects) a
reinterpretEnv = reinterpret2 handleEnv
runEnvState :: Environment address
-> Evaluator address value (Env address ': effects) a
-> Evaluator address value effects (a, Environment address)
runEnvState initial = fmap (uncurry filterEnv) . runState lowerBound . runState initial . reinterpretEnv
runEnvState initial = fmap (uncurry filterEnv) . runState lowerBound . runState initial . reinterpret2 handleEnv
where -- TODO: If the set of exports is empty because no exports have been
-- defined, do we export all terms, or no terms? This behavior varies across
-- languages. We need better semantics rather than doing it ad-hoc.