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

Add a convenience for constructing Live sets from addresses.

This commit is contained in:
Rob Rix 2018-05-10 19:15:05 -04:00
parent 44c4c5c78c
commit 9818589a92
2 changed files with 4 additions and 1 deletions

View File

@ -136,7 +136,7 @@ roots :: (Ord location, Foldable t) => Environment location value -> t Name -> L
roots env = foldMap (maybe mempty liveSingleton . flip lookup env)
addresses :: Ord location => Environment location value -> Live location value
addresses = Live . fromList . fmap snd . pairs
addresses = fromAddresses . map snd . pairs
instance Lower (Environment location value) where lowerBound = emptyEnv

View File

@ -10,6 +10,9 @@ import Prologue
newtype Live location value = Live { unLive :: Set (Address location value) }
deriving (Eq, Foldable, Lower, Monoid, Ord, Semigroup, Show)
fromAddresses :: (Foldable t, Ord location) => t (Address location value) -> Live location value
fromAddresses = Prologue.foldr liveInsert lowerBound
-- | Construct a 'Live' set containing only the given address.
liveSingleton :: Address location value -> Live location value
liveSingleton = Live . Set.singleton