ghc-lib-parser-9.14.1.20251220: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Data.List.SetOps

Description

Set-like operations on lists

Avoid using them as much as possible

Synopsis

- unionLists :: (HasDebugCallStack, Outputable a, Eq a) => [a] -> [a] -> [a]
- unionListsOrd :: (HasDebugCallStack, Outputable a, Ord a) => [a] -> [a] -> [a]
- minusList :: Ord a => [a] -> [a] -> [a]
- type Assoc a b = [(a, b)]
- assoc :: Eq a => String -> Assoc a b -> a -> b
- assocMaybe :: Eq a => Assoc a b -> a -> Maybe b
- assocUsing :: (a -> a -> Bool) -> String -> Assoc a b -> a -> b
- assocDefault :: Eq a => b -> Assoc a b -> a -> b
- assocDefaultUsing :: (a -> a -> Bool) -> b -> Assoc a b -> a -> b
- hasNoDups :: Eq a => [a] -> Bool
- removeDups :: (a -> a -> Ordering) -> [a] -> ([a], [NonEmpty a])
- removeDupsOn :: Ord b => (a -> b) -> [a] -> ([a], [NonEmpty a])
- nubOrdBy :: (a -> a -> Ordering) -> [a] -> [a]
- findDupsEq :: (a -> a -> Bool) -> [a] -> [NonEmpty a]
- equivClasses :: (a -> a -> Ordering) -> [a] -> [NonEmpty a]
- getNth :: Outputable a => [a] -> Int -> a
- isIn :: Eq a => String -> a -> [a] -> Bool
- isn'tIn :: Eq a => String -> a -> [a] -> Bool

# Documentation

unionLists :: (HasDebugCallStack, Outputable a, Eq a) => [a] -> [a] -> [a] #

Assumes that the arguments contain no duplicates

unionListsOrd :: (HasDebugCallStack, Outputable a, Ord a) => [a] -> [a] -> [a] #

Combines the two lists while keeping their order, placing the first argument first in the result.

Uses a set internally to record duplicates. This makes it slightly slower for very small lists but avoids quadratic behaviour for large lists.

minusList :: Ord a => [a] -> [a] -> [a] #

Calculate the set difference of two lists. This is O((m + n) log n), where we subtract a list of n elements from a list of m elements.

Extremely short cases are handled specially: When m or n is 0, this takes O(1) time. When m is 1, it takes O(n) time.

type Assoc a b = [(a, b)] #

A finite mapping based on equality and association lists.

assoc :: Eq a => String -> Assoc a b -> a -> b #

assocMaybe :: Eq a => Assoc a b -> a -> Maybe b #

Lookup key, fail gracefully using Nothing if not found.

assocUsing :: (a -> a -> Bool) -> String -> Assoc a b -> a -> b #

assocDefault :: Eq a => b -> Assoc a b -> a -> b #

assocDefaultUsing :: (a -> a -> Bool) -> b -> Assoc a b -> a -> b #

hasNoDups :: Eq a => [a] -> Bool #

removeDups :: (a -> a -> Ordering) -> [a] -> ([a], [NonEmpty a]) #

Remove the duplicates from a list using the provided comparison function. Might change the order of elements.

Returns the list without duplicates, and accumulates all the duplicates in the second component of its result.

removeDupsOn :: Ord b => (a -> b) -> [a] -> ([a], [NonEmpty a]) #

nubOrdBy :: (a -> a -> Ordering) -> [a] -> [a] #

Remove the duplicates from a list using the provided comparison function.

findDupsEq :: (a -> a -> Bool) -> [a] -> [NonEmpty a] #

equivClasses :: (a -> a -> Ordering) -> [a] -> [NonEmpty a] #

getNth :: Outputable a => [a] -> Int -> a #

isIn :: Eq a => String -> a -> [a] -> Bool #

isn'tIn :: Eq a => String -> a -> [a] -> Bool #