是否可以使用像下面这样的变量?显示变量的实例
instance Show Box where
show (Contents x y z) = "Contents " ++ x ++ " items, " ++ y ++ " items and " ++ z ++ " items"
这没有编译,有没有我加错了字符串,或者这通常不可能?
我试图写一个显示功能,具有以下效果;
示例:show(内容2 4 5)导致字符串“Contents 2 boxes,4 parcels and 5 letters”。
XYZ将是数字,是一个问题 – Lunar 2011-05-28 18:39:58
@Lunar:是的,它是。 – kennytm 2011-05-28 18:40:41
@Lunar'“Contents”++(show x)++ ...' – 2011-05-28 18:48:49