1
1
mirror of https://github.com/github/semantic.git synced 2025-01-04 13:34:31 +03:00

🔥 envUnion.

This commit is contained in:
Rob Rix 2018-03-13 11:27:46 -04:00
parent c34d378759
commit 83376c7277

View File

@ -20,9 +20,6 @@ envLookup k = Map.lookup k . unEnvironment
envInsert :: Name -> Address l a -> Environment l a -> Environment l a
envInsert name value (Environment m) = Environment (Map.insert name value m)
envUnion :: Environment l a -> Environment l a -> Environment l a
envUnion (Environment e1) (Environment e2) = Environment $ Map.union e1 e2
bindEnv :: (Ord l, Foldable t) => t Name -> Environment l a -> Environment l a
bindEnv names env = Environment (Map.fromList pairs)
where pairs = foldr (\name b -> maybe b (\v -> (name, v) : b) (envLookup name env)) mempty names