1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 14:21:31 +03:00

Change bindExports to take a Map

This commit is contained in:
joshvera 2018-03-07 15:00:10 -05:00
parent db9a816163
commit 1f3ed79c01

View File

@ -27,10 +27,11 @@ bindEnv :: (Ord l, Foldable t) => t Name -> Environment l a -> Environment l a
bindEnv names env = Environment (Map.fromList pairs) bindEnv names env = Environment (Map.fromList pairs)
where pairs = foldr (\name b -> maybe b (\v -> (name, v) : b) (envLookup name env)) mempty names where pairs = foldr (\name b -> maybe b (\v -> (name, v) : b) (envLookup name env)) mempty names
bindExports :: (Ord l, Foldable t) => t (Name, Name) -> Environment l a -> Environment l a bindExports :: (Ord l) => Map Name (Name, Maybe (Address l a)) -> Environment l a -> Environment l a
bindExports aliases env = Environment pairs bindExports aliases env = Environment pairs
where where
pairs = foldr (\(name, alias) b -> maybe b (\v -> Map.insert alias v b) (envLookup name env)) mempty aliases pairs = Map.foldrWithKey (\name (alias, address) accum ->
maybe accum (\v -> Map.insert alias v accum) (address <|> envLookup name env)) mempty aliases
-- | Retrieve the 'Live' set of addresses to which the given free variable names are bound. -- | Retrieve the 'Live' set of addresses to which the given free variable names are bound.
-- --