KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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 = Prediction Int Int Int showPrediction :: Prediction -> String showPrediction (Prediction a b c) = show a ++ "-" ++ show b ++ "-" ++ show c instance Show (Prediction p) => showPrediction p Seems the last line is wrong but I'm not sure how to achieve what I want. Basically is to be able to call from the interpreter a Prediction variable and get it visualized without having to call the showPrediction. Right now this works: showPrediction (Prediction 1 2 3) and shows: "1-2-3" as expected, but I would like this to work (from the interpreter): Prediction 1 2 3 Any ideas?
Tags (comma-separated)
Save Edits
Cancel