1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 22:31:36 +03:00

Define the symmetric difference on live sets.

This commit is contained in:
Rob Rix 2017-12-01 14:27:50 -05:00
parent 40d004a289
commit 67c633f3b0

View File

@ -3,6 +3,7 @@ module Data.Abstract.Live where
import Data.Abstract.Address
import Data.Bifunctor (second)
import Data.Function (on)
import Data.Functor.Classes.Generic
import Data.Semigroup
import Data.Set as Set
@ -18,6 +19,9 @@ singleton = Live . Set.singleton
delete :: Ord l => Address l v -> Live l v -> Live l v
delete addr (Live s) = Live (Set.delete addr s)
difference :: Ord l => Live l v -> Live l v -> Live l v
difference = fmap Live . (Set.difference `on` unLive)
member :: Ord l => Address l v -> Live l v -> Bool
member addr = Set.member addr . unLive