I\'m trying to add an instance declaration in Haskell for a new data type I\'ve created unsuccessfully. Here what I\'ve tried so far:
data Prediction = Predictio
You've got the syntax for instances wrong. To create an instance of Show
write:
instance Show Foo where
show = ...
-- or
show x = ...
where ...
contains your definition of the show
function for Foo
.
So in this case you want:
instance Show Prediction where
show = showPrediction
or, since there isn't an important reason to have showPrediction
at all:
instance Show Prediction where
show (Prediction a b c) = show a ++ "-" ++ show b ++ "-" ++ show c