Hey everyone I am working on a piece of Haskell code and cannot figure out how to fix this problem.
I get this error:
Couldn't match expected type `Collection' with actual type `[a0]'
In the expression: [list] ++ numberToInsert
In an equation for `insert':
insert numberToInsert (Set [list])
| contains (Set [list]) numberToInsert == True = (Set [list])
| otherwise = [list] ++ numberToInsert
Failed, modules loaded: none.
Here is my code
data Collection = Set [Int] deriving (Show)
insert :: Int -> Collection -> Collection
insert numberToInsert (Set [list])
|contains (Set [list]) numberToInsert == True = (Set [list])
|otherwise = [list] ++ numberToInsert <--- this is my problem
contains :: Collection -> Int -> Bool
contains (Set []) numberToFind = False
contains (Set (x:xs)) numberToFind
|x == numberToFind = True
|otherwise = contains (Set (xs)) numberToFind
Can someone help me fix this?
Thanks