Simon Jakobi pushed to branch wip/sjakobi/set-ops at Glasgow Haskell Compiler / GHC
Commits:
-
092fcbbe
by Simon Jakobi at 2026-05-25T09:06:36+02:00
1 changed file:
Changes:
| ... | ... | @@ -60,12 +60,13 @@ getNth xs n = assertPpr (xs `lengthExceeds` n) (ppr n $$ ppr xs) $ |
| 60 | 60 | --
|
| 61 | 61 | -- Uses a set internally to record duplicates. This makes it slightly slower for
|
| 62 | 62 | -- very small lists but avoids quadratic behaviour for large lists.
|
| 63 | -unionListsOrd :: (HasDebugCallStack, Outputable a, Ord a) => [a] -> [a] -> [a]
|
|
| 63 | +unionListsOrd :: Ord a => [a] -> [a] -> [a]
|
|
| 64 | 64 | unionListsOrd xs ys
|
| 65 | - -- Since both arguments don't have internal duplicates we can just take all of xs
|
|
| 66 | - -- and every element of ys that's not already in xs.
|
|
| 65 | + -- Since both arguments don't have internal duplicates we can just take all of ys
|
|
| 66 | + -- and every element of xs that's not already in ys.
|
|
| 67 | 67 | = let set_ys = S.fromList ys
|
| 68 | 68 | in (filter (\e -> not $ S.member e set_ys) xs) ++ ys
|
| 69 | +{-# INLINABLE unionListsOrd #-} -- Ensure the function can be specialized.
|
|
| 69 | 70 | |
| 70 | 71 | -- | Assumes that the arguments contain no duplicates
|
| 71 | 72 | unionLists :: (HasDebugCallStack, Outputable a, Eq a) => [a] -> [a] -> [a]
|
| ... | ... | @@ -108,6 +109,7 @@ minusList xs [y] = filter (/= y) xs |
| 108 | 109 | minusList xs ys = filter (`S.notMember` yss) xs
|
| 109 | 110 | where
|
| 110 | 111 | yss = S.fromList ys
|
| 112 | +{-# INLINABLE minusList #-} -- Ensure the function can be specialized.
|
|
| 111 | 113 | |
| 112 | 114 | {-
|
| 113 | 115 | ************************************************************************
|