From 74067b20c2fc8c8d268e7bc86817d7cdf9cf59c9 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 30 May 2018 08:14:57 -0400 Subject: [PATCH] Exports operates on locations. --- src/Control/Abstract/Exports.hs | 2 +- src/Data/Abstract/Exports.hs | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Control/Abstract/Exports.hs b/src/Control/Abstract/Exports.hs index e31e8d376..b9c8a307d 100644 --- a/src/Control/Abstract/Exports.hs +++ b/src/Control/Abstract/Exports.hs @@ -26,7 +26,7 @@ modifyExports = modify' -- | Add an export to the global export state. addExport :: Member (State (Exports location)) effects => Name -> Name -> Maybe (Address location value) -> Evaluator location value effects () -addExport name alias = modifyExports . insert name alias +addExport name alias = modifyExports . insert name alias . fmap unAddress -- | Sets the global export state for the lifetime of the given action. withExports :: Member (State (Exports location)) effects => Exports location -> Evaluator location value effects a -> Evaluator location value effects a diff --git a/src/Data/Abstract/Exports.hs b/src/Data/Abstract/Exports.hs index 405c8bba8..413b5fdef 100644 --- a/src/Data/Abstract/Exports.hs +++ b/src/Data/Abstract/Exports.hs @@ -7,13 +7,12 @@ module Data.Abstract.Exports , toEnvironment ) where -import Prelude hiding (null) -import Prologue hiding (null) -import Data.Abstract.Address import Data.Abstract.Environment (Environment, unpairs) import Data.Abstract.Name import qualified Data.Map as Map import Data.Semilattice.Lower +import Prelude hiding (null) +import Prologue hiding (null) -- | A map of export names to an alias & address tuple. newtype Exports location = Exports { unExports :: Map.Map Name (Name, Maybe location) } @@ -25,8 +24,8 @@ null = Map.null . unExports toEnvironment :: Exports location -> Environment location toEnvironment exports = unpairs (mapMaybe sequenceA (toList (unExports exports))) -insert :: Name -> Name -> Maybe (Address location value) -> Exports location -> Exports location -insert name alias address = Exports . Map.insert name (alias, unAddress <$> address) . unExports +insert :: Name -> Name -> Maybe location -> Exports location -> Exports location +insert name alias address = Exports . Map.insert name (alias, address) . unExports -- TODO: Should we filter for duplicates here? aliases :: Exports location -> [(Name, Name)]