1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 06:41:45 +03:00

Add union.

This commit is contained in:
Rob Rix 2015-12-11 17:34:31 -05:00
parent 3f7e74e3cb
commit d806e7407a

View File

@ -7,6 +7,7 @@ module OrderedMap (
, OrderedMap.lookup
, size
, empty
, union
) where
data OrderedMap key value = OrderedMap { toList :: [(key, value)] }
@ -33,3 +34,7 @@ size = length . toList
empty :: OrderedMap key value
empty = OrderedMap []
union :: Eq key => OrderedMap key value -> OrderedMap key value -> OrderedMap key value
union (OrderedMap a) (OrderedMap b) = OrderedMap $ a ++ filter ((`elem` extant) . fst) b
where extant = fst <$> a