1
1
mirror of https://github.com/github/semantic.git synced 2024-12-29 18:06:14 +03:00

Merge branch 'env-effect' of https://github.com/github/semantic into env-effect

This commit is contained in:
Rob Rix 2018-05-30 12:20:22 -04:00
commit 8cfc4ad9ee
2 changed files with 14 additions and 5 deletions

View File

@ -71,7 +71,11 @@ data Env address return where
Push :: Env address ()
Pop :: Env address ()
handleEnv :: Member (Env address) effects => Environment address -> Env address result -> Evaluator address value effects result
handleEnv :: forall address effects value result
. Member (State (Environment address)) effects
=> Environment address
-> Env address result
-> Evaluator address value effects result
handleEnv defaultEnvironment = \case
Lookup name -> maybe (Env.lookup name defaultEnvironment) Just . Env.lookup name <$> getEnv
Bind name addr -> modifyEnv (Env.insert name addr)
@ -79,10 +83,15 @@ handleEnv defaultEnvironment = \case
Push -> modifyEnv Env.push
Pop -> modifyEnv Env.pop
runEnv :: Member (Env address) effects => Environment address -> Evaluator address value (Env address ': effects) a -> Evaluator address value effects a
runEnv :: Member (State (Environment address)) effects
=> Environment address
-> Evaluator address value (Env address ': effects) a
-> Evaluator address value effects a
runEnv defaultEnvironment = interpret (handleEnv defaultEnvironment)
reinterpretEnv :: Environment address -> Evaluator address value (Env address ': effects) a -> Evaluator address value (Env address ': effects) a
reinterpretEnv :: Environment address
-> Evaluator address value (Env address ': effects) a
-> Evaluator address value (State (Environment address) ': effects) a
reinterpretEnv defaultEnvironment = reinterpret (handleEnv defaultEnvironment)

View File

@ -121,7 +121,7 @@ instance ( Member (Allocator address Type) effects
, Member Fresh effects
, Member (Resumable TypeError) effects
, Member (Return Type) effects
, Member (State (Heap location (Cell address) Type)) effects
, Member (State (Heap address (Cell address) Type)) effects
, Ord address
, Reducer Type (Cell address Type)
)
@ -151,7 +151,7 @@ instance ( Member (Allocator address Type) effects
, Member NonDet effects
, Member (Resumable TypeError) effects
, Member (Return Type) effects
, Member (State (Heap location (Cell address) Type)) effects
, Member (State (Heap address (Cell address) Type)) effects
, Ord address
, Reducer Type (Cell address Type)
)