1
1
mirror of https://github.com/github/semantic.git synced 2024-12-30 02:14:20 +03:00

Generalize lookupWith.

This commit is contained in:
Rob Rix 2018-05-02 19:16:24 -04:00
parent a7306d9f73
commit 56c67158cf

View File

@ -162,7 +162,7 @@ lookupEnv :: (Evaluator location term value m, Members '[Reader (Environment loc
lookupEnv name = (<|>) <$> (Env.lookup name <$> getEnv) <*> (Env.lookup name <$> defaultEnvironment)
-- | Look up a 'Name' in the environment, running an action with the resolved address (if any).
lookupWith :: MonadEvaluator location term value effects m => (Address location value -> m effects a) -> Name -> m effects (Maybe a)
lookupWith :: (Evaluator location term value m, Members '[Reader (Environment location value), State (Environment location value)] effects, Monad (m effects)) => (Address location value -> m effects a) -> Name -> m effects (Maybe a)
lookupWith with name = do
addr <- lookupEnv name
maybe (pure Nothing) (fmap Just . with) addr