I am a newbie to Haskell and Iam trying to implement Set
ADT with one function named union
using Lists
.here below is the code :
import Data.List
data Set a = Set [a]
union' :: Set a -> Set a -> Set a
union' xs [] = xs
union' [] ys = ys
union' x:xs ys = | not $ x:xs `elem` ys = x:union' xs ys
| otherwise union xs ys
I think am doing something terribly wrong here in type allocation. while compiling it's showing an error as below
error: parse error on input `::'
union' :: Set a -> Set a -> Set a
pardon me for such silly mistakes but any help would be appreciated, Thank you
union'
(union prime), but your function is calledunion
- it might not be related, but you might want to clean it up anyway. - Wander NautanotElem
is a thing, btw. - melpomene