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
|
( Environment
|
||||||
, getEnv
|
, getEnv
|
||||||
, putEnv
|
, putEnv
|
||||||
, withEnv
|
|
||||||
, lookupEnv
|
, lookupEnv
|
||||||
, bind
|
, bind
|
||||||
, bindAll
|
, bindAll
|
||||||
@ -33,15 +32,6 @@ getEnv = send GetEnv
|
|||||||
putEnv :: Member (Env address) effects => Environment address -> Evaluator address value effects ()
|
putEnv :: Member (Env address) effects => Environment address -> Evaluator address value effects ()
|
||||||
putEnv = send . PutEnv
|
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.
|
-- | 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)
|
lookupEnv :: Member (Env address) effects => Name -> Evaluator address value effects (Maybe address)
|
||||||
|
Loading…
Reference in New Issue
Block a user