问题
I'm still very new to Haskell, and I'm curious as to how I would merge two Hand
's together, so that, the first hand is placed on top of the second hand. I want it to be an infix operator, namely (<+). Here's some code to assist you. I keep getting an error saying "The type signature for ‘<+’ lacks an accompanying binding".
data Rank = Numeric Integer | Jack | Queen | King | Ace
data Suit = Hearts | Spades | Diamonds | Clubs
data Card = Card Rank Suit
data Hand = Empty | Add Card Hand
(<+) :: Hand -> Hand -> Hand
h1 (<+) h2 = undefined
Many thanks in advance for any advice given.
回答1:
The definition should either be
h1 <+ h2 = undefined
or
(<+) h1 h2 = undefined
You are currently trying to use a function name as an infix operator.
来源:https://stackoverflow.com/questions/58938019/how-to-merge-two-hands-of-cards-together-in-haskell