mirror of
https://github.com/github/semantic.git
synced 2024-12-22 06:11:49 +03:00
Rename a bunch of type parameters.
This commit is contained in:
parent
602728b54d
commit
a916074ef9
@ -8,36 +8,36 @@ import Prologue
|
||||
import Unsafe.Coerce
|
||||
|
||||
-- | A set of live addresses (whether roots or reachable).
|
||||
newtype Live l v = Live { unLive :: Set (Address l v) }
|
||||
newtype Live location value = Live { unLive :: Set (Address location value) }
|
||||
deriving (Eq, Foldable, Lower, Monoid, Ord, Semigroup, Show)
|
||||
|
||||
-- | Construct a 'Live' set containing only the given address.
|
||||
liveSingleton :: Address l v -> Live l v
|
||||
liveSingleton :: Address location value -> Live location value
|
||||
liveSingleton = Live . Set.singleton
|
||||
|
||||
-- | Insert an address into a 'Live' set.
|
||||
liveInsert :: Ord l => Address l v -> Live l v -> Live l v
|
||||
liveInsert :: Ord location => Address location value -> Live location value -> Live location value
|
||||
liveInsert addr = Live . Set.insert addr . unLive
|
||||
|
||||
-- | Delete an address from a 'Live' set, if present.
|
||||
liveDelete :: Ord l => Address l v -> Live l v -> Live l v
|
||||
liveDelete :: Ord location => Address location value -> Live location value -> Live location value
|
||||
liveDelete addr = Live . Set.delete addr . unLive
|
||||
|
||||
-- | Compute the (asymmetric) difference of two 'Live' sets, i.e. delete every element of the second set from the first set.
|
||||
liveDifference :: Ord l => Live l v -> Live l v -> Live l v
|
||||
liveDifference :: Ord location => Live location value -> Live location value -> Live location value
|
||||
liveDifference = fmap Live . (Set.difference `on` unLive)
|
||||
|
||||
-- | Test whether an 'Address' is in a 'Live' set.
|
||||
liveMember :: Ord l => Address l v -> Live l v -> Bool
|
||||
liveMember :: Ord location => Address location value -> Live location value -> Bool
|
||||
liveMember addr = Set.member addr . unLive
|
||||
|
||||
-- | Decompose a 'Live' set into a pair of one member address and the remaining set, or 'Nothing' if empty.
|
||||
liveSplit :: Live l v -> Maybe (Address l v, Live l v)
|
||||
liveSplit :: Live location value -> Maybe (Address location value, Live location value)
|
||||
liveSplit = fmap (second Live) . Set.minView . unLive
|
||||
|
||||
|
||||
instance Generic1 (Live l) where
|
||||
type Rep1 (Live l)
|
||||
instance Generic1 (Live location) where
|
||||
type Rep1 (Live location)
|
||||
= D1
|
||||
('MetaData "Live" "Data.Abstract.Live" "main" 'True)
|
||||
(C1
|
||||
@ -48,14 +48,14 @@ instance Generic1 (Live l) where
|
||||
'NoSourceUnpackedness
|
||||
'NoSourceStrictness
|
||||
'DecidedLazy)
|
||||
(Set :.: Rec1 (Address l))))
|
||||
-- NB: The value type @v@ in @'Address' l v@ is phantom; 'compare'ing 'Address'es is based solely on the location type @l@. Thus, we can safely coerce the values in the 'Set' without worrying about changing its shape. However, 'Set.map' would require that we add an extra 'Ord' constraint since it needs to account for the possibility of changing the shape of the set; so we use 'unsafeCoerce' to circumvent that possibility.
|
||||
(Set :.: Rec1 (Address location))))
|
||||
-- NB: The value type @value@ in @'Address' location value@ is phantom; 'compare'ing 'Address'es is based solely on the location type @location@. Thus, we can safely coerce the values in the 'Set' without worrying about changing its shape. However, 'Set.map' would require that we add an extra 'Ord' constraint since it needs to account for the possibility of changing the shape of the set; so we use 'unsafeCoerce' to circumvent that possibility.
|
||||
to1 = Live . unsafeCoerce . unComp1 . unM1 . unM1 . unM1
|
||||
from1 = M1 . M1 . M1 . Comp1 . unsafeCoerce . unLive
|
||||
|
||||
instance Ord l => Functor (Live l) where
|
||||
instance Ord location => Functor (Live location) where
|
||||
fmap _ = Live . unsafeCoerce . unLive
|
||||
|
||||
instance Eq l => Eq1 (Live l) where liftEq = genericLiftEq
|
||||
instance Ord l => Ord1 (Live l) where liftCompare = genericLiftCompare
|
||||
instance Show l => Show1 (Live l) where liftShowsPrec = genericLiftShowsPrec
|
||||
instance Eq location => Eq1 (Live location) where liftEq = genericLiftEq
|
||||
instance Ord location => Ord1 (Live location) where liftCompare = genericLiftCompare
|
||||
instance Show location => Show1 (Live location) where liftShowsPrec = genericLiftShowsPrec
|
||||
|
Loading…
Reference in New Issue
Block a user