Is it possible to use a variable like below?
instance Show Box where
show (Contents x y z) = "Contents " ++ x ++ " items, " ++ y ++ " items and " ++ z ++ " items"
This doesnt compile, have i added the string together wrong, or this generally not possible?
Im trying to write a show function that has the following effect;
EXAMPLE: show (Contents 2 4 5) results in the string “Contents 2 boxes, 4 parcels and 5 letters”.
I guess you have something like this:
data Box = Contents Integer Integer IntegerSince
Integerhas aShow-instance, just try the following: (And BTW, using(.)here, is more efficient than using++)