I have a problem when trying to type match with tuple.
filterSth :: [a]->[b]->([a],[b])
filterSth _ [] = (_, [])
It means that when the second argument is an empty list, I don’t care the first element of the tuple that I wish to return.
How can I implement this ?
If you don’t care about the first element of the tuple and you’re sure you won’t use it you can return
undefined, i.e.Remember that trying to evaluate
undefinedwill result in a runtime exception.Another idea might be to return
Either ([a], [b]) [b]instead.If you want to return the first argument unchanged you cannot use
_._means that you don’t care what’s the value of the argument and you’re not going to use it. Since you are going to use it you have to replace_with a named argument and explicitly return it