First, the type signature is incorrect.
deleteAllInstances :: (a, [l]) => a -> [l] -> [l]
The type signature has the form
name :: (Constraints) => type
where Constraintsinclude type classes such as (Ord a, Show a). In this case, the function uses (==), so there should be a form limitation Eq a.
Then the definition of the function does not correspond to the part of the type, you defined it to take a pair as an argument, while the signature of the type says otherwise (your definition is not fulfilled, the type has the value curried).
deleteAllInstances (a, []) = []
deleteAllInstances (i, (x:xs))
| i == x = tail
| otherwise = x ++ tail
where tail = deleteAllInstances i xs
(++) , (++) , (:) .
- filter
deleteAllInstances :: Eq a => a -> [a] -> [a]
deleteAllInstances a xs = filter (/= a) xs
,
deleteAllInstances :: Eq a => a -> [a] -> [a]
deleteAllInstances a (x:xs)
| a == x = rest
| otherwise = x : rest
where
rest = deleteAllInstances a xs
deleteAllInstances _ _ = []