1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 06:11:49 +03:00

Rename the type parameters to Exports.

This commit is contained in:
Rob Rix 2018-05-10 19:42:01 -04:00
parent 1fa5f9a44b
commit b164fcff30

View File

@ -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