mirror of
https://github.com/github/semantic.git
synced 2024-12-26 08:25:19 +03:00
Add a difference
binding.
This commit is contained in:
parent
92a28ad38a
commit
8819f02306
@ -10,6 +10,7 @@ module OrderedMap (
|
||||
, union
|
||||
, unions
|
||||
, intersectionWith
|
||||
, difference
|
||||
) where
|
||||
|
||||
data OrderedMap key value = OrderedMap { toList :: [(key, value)] }
|
||||
@ -46,3 +47,7 @@ unions = foldl union empty
|
||||
|
||||
intersectionWith :: Eq key => (a -> b -> c) -> OrderedMap key a -> OrderedMap key b -> OrderedMap key c
|
||||
intersectionWith combine (OrderedMap a) (OrderedMap b) = OrderedMap $ a >>= (\ (key, value) -> maybe [] (pure . ((,) key) . combine value) $ Prelude.lookup key b)
|
||||
|
||||
difference :: Eq key => OrderedMap key a -> OrderedMap key b -> OrderedMap key a
|
||||
difference (OrderedMap a) (OrderedMap b) = OrderedMap $ filter (not . (`elem` extant) . fst) a
|
||||
where extant = fst <$> b
|
||||
|
Loading…
Reference in New Issue
Block a user