diff --git a/src/Data/Abstract/Exports.hs b/src/Data/Abstract/Exports.hs index 915f9da32..c631fb61d 100644 --- a/src/Data/Abstract/Exports.hs +++ b/src/Data/Abstract/Exports.hs @@ -16,25 +16,25 @@ import qualified Data.Map as Map import Data.Semilattice.Lower -- | A map of export names to an alias & address tuple. -newtype Exports l a = Exports { unExports :: Map.Map Name (Name, Maybe (Address l a)) } +newtype Exports location value = Exports { unExports :: Map.Map Name (Name, Maybe (Address location value)) } deriving (Eq, Foldable, Functor, Generic1, Lower, Monoid, Ord, Semigroup, Show, Traversable) -null :: Exports l a -> Bool +null :: Exports location value -> Bool null = Map.null . unExports -toEnvironment :: Exports l a -> Environment l a +toEnvironment :: Exports location value -> Environment location value toEnvironment exports = unpairs (mapMaybe collectExport (toList (unExports exports))) where collectExport (_, Nothing) = Nothing - collectExport (n, Just a) = Just (n, a) + collectExport (n, Just value) = Just (n, value) -insert :: Name -> Name -> Maybe (Address l a) -> Exports l a -> Exports l a +insert :: Name -> Name -> Maybe (Address location value) -> Exports location value -> Exports location value insert name alias address = Exports . Map.insert name (alias, address) . unExports -- TODO: Should we filter for duplicates here? -aliases :: Exports l a -> [(Name, Name)] +aliases :: Exports location value -> [(Name, Name)] aliases = Map.toList . fmap fst . unExports -instance Eq l => Eq1 (Exports l) where liftEq = genericLiftEq -instance Ord l => Ord1 (Exports l) where liftCompare = genericLiftCompare -instance Show l => Show1 (Exports l) where liftShowsPrec = genericLiftShowsPrec +instance Eq location => Eq1 (Exports location) where liftEq = genericLiftEq +instance Ord location => Ord1 (Exports location) where liftCompare = genericLiftCompare +instance Show location => Show1 (Exports location) where liftShowsPrec = genericLiftShowsPrec