2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1995
4 \section[ListSetOps]{Set-like operations on lists}
11 #if ! defined(COMPILING_GHC)
12 , disjointLists, intersectingLists
16 #if defined(COMPILING_GHC)
18 # ifdef USE_ATTACK_PRAGMAS
26 unionLists :: (Eq a) => [a] -> [a] -> [a]
31 | a `is_elem` b = unionLists as b
32 | otherwise = a : unionLists as b
34 #if defined(COMPILING_GHC)
35 is_elem = isIn "unionLists"
40 intersectLists :: (Eq a) => [a] -> [a] -> [a]
41 intersectLists [] [] = []
42 intersectLists [] b = []
43 intersectLists a [] = []
44 intersectLists (a:as) b
45 | a `is_elem` b = a : intersectLists as b
46 | otherwise = intersectLists as b
48 #if defined(COMPILING_GHC)
49 is_elem = isIn "intersectLists"
55 Everything in the first list that is not in the second list:
57 minusList :: (Eq a) => [a] -> [a] -> [a]
58 minusList xs ys = [ x | x <- xs, x `not_elem` ys]
60 #if defined(COMPILING_GHC)
61 not_elem = isn'tIn "minusList"
68 #if ! defined(COMPILING_GHC)
70 disjointLists, intersectingLists :: Eq a => [a] -> [a] -> Bool
72 disjointLists [] bs = True
73 disjointLists (a:as) bs
75 | otherwise = disjointLists as bs
77 intersectingLists xs ys = not (disjointLists xs ys)
82 #if defined(COMPILING_GHC)
83 # ifdef USE_ATTACK_PRAGMAS
85 {-# SPECIALIZE unionLists :: [TyVar] -> [TyVar] -> [TyVar] #-}
86 {-# SPECIALIZE intersectLists :: [TyVar] -> [TyVar] -> [TyVar] #-}
88 {-# SPECIALIZE minusList :: [TyVar] -> [TyVar] -> [TyVar],
90 [Int] -> [Int] -> [Int]