I have been working on a problem whereby I have a list of tuples consisting of songName, artistName and sales. I am required to retrieve either the quantity of sales using the songName and artistName, and if the tuple containing this infomation isn't in the list, I must return 0.
I have attempted to solve this problem with the solution below:
testData :: [Sales]
testData = [("No Lie", "Sean Paul feat. Dua Lipa", 100),
("Yes Lie", "Sean Paul feat. Dua Lipa", 10),
("Fear & Delight", "The Correspondents", 120)]
findSales :: [Sales] -> String -> String -> Int
findSales ((track, artist,qty): xs) trackName artistName
| track == trackName && artist == artistName = qty
| otherwise = 0
However, when I enter a legit query like findSales testData "Yes Lie" "Sean Paul feat. Dua Lipa" whereby I expect this to be included in the list of tuples and therefore return 10, the program returns 0, the edge case instead.
Where am I going wrong whereby the edge case is always being returned?
And is there a good tool/Extension that I could use in VS Code, so that I could use to easily debug the program in the future. I have tried to use Haskelly/Heskero, but I wasn't able to get them working when trying to set them up.