mirror of
https://github.com/github/semantic.git
synced 2024-12-22 14:21:31 +03:00
Add a convenience for constructing Live sets from addresses.
This commit is contained in:
parent
44c4c5c78c
commit
9818589a92
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user