List union implementation I'm trying to implement union from the standard Data.List library. I know it's reinventing the wheel, but reimplementing functions is how I learn things. Any feedback at all would be helpful!

union' :: (Eq a) =&gt; [a] -&gt; [a] -&gt; [a]
union' [] _ = []
union' _ [] = []
union' xs ys = nub' $ xs ++ ys where 
    nub' [] = []
    nub' (x:xs)
        | not $ x `elem` xs = x : nub' xs
        | otherwise = nub' xs


This code works, but it strikes me as verbose. union is the opposite of intersect, which does not require a helper where statement:

intersect' :: (Eq a) =&gt; [a] -&gt; [a] -&gt; [a]
intersect' [] _ = []
intersect' _ [] = []
intersect' (x:xs) list
    | x `elem` list = x : intersect' xs list
    | otherwise = intersect' xs list


How can I make my union function resemble the elegance of my intersect function?

Revision here
Your base cases are both invalid and unnecessary:


union' [] _ = []
union' _ [] = []



There isn't anything bad about using where, especially when you consider that union' needs no base cases.  Your question is, really, whether union' should be implemented using some kind of nub or not.  If you're reinventing-the-wheel as an exercise, why wouldn't you want to reimplement nub as well?

The real question you should be asking is how to avoid ++.