mirror of
https://github.com/github/semantic.git
synced 2024-11-28 10:15:55 +03:00
🔥 withEnv.
This commit is contained in:
parent
c9360b2c61
commit
adfa93f6c9
@ -3,7 +3,6 @@ module Control.Abstract.Environment
|
||||
( Environment
|
||||
, getEnv
|
||||
, putEnv
|
||||
, withEnv
|
||||
, lookupEnv
|
||||
, bind
|
||||
, bindAll
|
||||
@ -33,15 +32,6 @@ getEnv = send GetEnv
|
||||
putEnv :: Member (Env address) effects => Environment address -> Evaluator address value effects ()
|
||||
putEnv = send . PutEnv
|
||||
|
||||
-- | Sets the environment for the lifetime of the given action.
|
||||
withEnv :: Member (Env address) effects => Environment address -> Evaluator address value effects a -> Evaluator address value effects a
|
||||
withEnv env m = do
|
||||
oldEnv <- getEnv
|
||||
putEnv env
|
||||
result <- m
|
||||
putEnv oldEnv
|
||||
pure result
|
||||
|
||||
|
||||
-- | Look a 'Name' up in the current environment, trying the default environment if no value is found.
|
||||
lookupEnv :: Member (Env address) effects => Name -> Evaluator address value effects (Maybe address)
|
||||
|
Loading…
Reference in New Issue
Block a user