diff --git a/src/Control/Abstract/Value.hs b/src/Control/Abstract/Value.hs index 159bda073..e924cc171 100644 --- a/src/Control/Abstract/Value.hs +++ b/src/Control/Abstract/Value.hs @@ -29,6 +29,9 @@ class (MonadEvaluator t v m) => MonadValue t v m where -- | Construct an abstract string value. string :: ByteString -> m v + -- | Construct an abstract interface value. + interface :: v -> m v + -- | Eliminate boolean values. TODO: s/boolean/truthy ifthenelse :: v -> m v -> m v -> m v @@ -40,8 +43,6 @@ class (MonadEvaluator t v m) => MonadValue t v m where -- | Extract the environment from an interface value. environment :: v -> m (EnvironmentFor v) - interface :: v -> m v - -- | Construct a 'Value' wrapping the value arguments (if any). instance ( FreeVariables t , MonadAddressable location (Value location t) m diff --git a/src/Data/Syntax/Declaration.hs b/src/Data/Syntax/Declaration.hs index f6928ba04..37b6ab793 100644 --- a/src/Data/Syntax/Declaration.hs +++ b/src/Data/Syntax/Declaration.hs @@ -232,20 +232,16 @@ instance Evaluatable Import2 where env <- getGlobalEnv putGlobalEnv mempty importedEnv <- require name - env' <- Map.foldrWithKey (\k v rest -> do - if Map.null symbols - -- Copy over all symbols in the environment under their qualified names. - then envInsert (prefix <> k) v <$> rest - -- Only copy over specified symbols, possibly aliasing them. - else maybe rest (\symAlias -> envInsert symAlias v <$> rest) (Map.lookup k symbols) - ) (pure env) (unEnvironment importedEnv) - + env' <- Map.foldrWithKey copy (pure env) (unEnvironment importedEnv) modifyGlobalEnv (const env') unit where name = qualifiedName (subterm from) - symbols = Map.fromList xs prefix = qualifiedName (subterm alias) <> "." + symbols = Map.fromList xs + copy = if Map.null symbols then qualifyInsert else directInsert + qualifyInsert k v rest = envInsert (prefix <> k) v <$> rest + directInsert k v rest = maybe rest (\symAlias -> envInsert symAlias v <$> rest) (Map.lookup k symbols) -- | A wildcard import