我有以下类型:
data Suit = Club | Diamond | Heart | Spade deriving Show
data Rank = R2 | R3 | R4 | R5 | R6 | R7 | R8 | R9 | R10 | Jack | Queen | King | Ace deriving Show
data JokerColor = Red | Black deriving Show
data JCard = NormalCard Suit Rank | JokerCard JokerColor
如何展示JCard?目前我得到No instance for (Show JCard)
答案 0 :(得分:10)
以与JCard
相同的方式导出JokerColor
的节目。
data JokerColor = Red | Black deriving Show
data JCard = NormalCard Suit Rank | JokerCard JokerColor deriving Show
对于大多数类型,人们通常派生Eq,Ord和Show。