I have created two objects in Haskell, mainly a trump card and the cards in hand.
trump = Card Spade Two
myhand = [Card Diamond Three, Card Spade Two]
where card is denoted by:
data Card = Card Suit Rank
I have written a function called retrieveSuit which retrieves the suit of the cards which are spades, diamonds,hearts etc..
retrieveSuit :: Card -> Suit
retrieveSuit (Card suit _) = suit
The problem I'm having is that I'm trying to write a function that compares both the suits of the trump and hand cards and see if the hand cards contain the suit of the trump card but I'm having issue mapping across both arguments of trump and myhand as I only know how to map one argument but not both.
checkTrump :: Card -> [Card] -> Bool
checkTrump trump myhand = (map retrieveSuit myhand) (retrieveSuit trump) if trump == myhand then True else False
when i run, i get the error
error: parse error on input `if'
Am i applying the function retrieveSuit correctly to both arguments of checkTrump? In this case, the program would output True since the cards in hand does contain a Spade which is the suit of the trump card as well.
Edit: Update for second scenario. Instead of returning true or false, if i were to return the card in hand that has the same suit as trump:
checkTrump :: Card -> [Card] -> Card
checkTrump trump myhand = filter ((cardSuit trump) `elem` (map cardSuit myhand))