mirror of
https://github.com/github/semantic.git
synced 2024-12-01 00:33:59 +03:00
📝 bind/bindAll.
This commit is contained in:
parent
01b30e5ae1
commit
dcf4b9abc7
@ -51,9 +51,11 @@ withDefaultEnvironment e = local (const e)
|
||||
lookupEnv :: (Member (Reader (Environment location)) effects, Member (State (Environment location)) effects) => Name -> Evaluator location value effects (Maybe (Address location value))
|
||||
lookupEnv name = (<|>) <$> (fmap Address . Env.lookup name <$> getEnv) <*> (fmap Address . Env.lookup name <$> defaultEnvironment)
|
||||
|
||||
-- | Bind a 'Name' to an 'Address' in the current scope.
|
||||
bind :: Member (State (Environment location)) effects => Name -> Address location value -> Evaluator location value effects ()
|
||||
bind name = modifyEnv . Env.insert name . unAddress
|
||||
|
||||
-- | Bind all of the names from an 'Environment' in the current scope.
|
||||
bindAll :: Member (State (Environment location)) effects => Environment location -> Evaluator location value effects ()
|
||||
bindAll = foldr ((>>) . uncurry bind . second Address) (pure ()) . pairs
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user