Question:Define a new Rating type with the constructors One, Two, .. Five. It should
derive Ord, Eq and Enum behaviors
Make the new type an instance of Show, giving the displays as the appropriate number
of stars (i.e., "*", "**" and so on) My program: import System.IO
import Data.List
main = do --Main function
data Rating = One | Two | Three | Four | Five deriving (Eq, Ord, Show, Enum) {-Created a new Rating datatype with constructors One,Two..Five deriving Ord,Eq,Enum behaviours
instance Show Rating where --Creating New instance of show show One ""
show Two "" show Three "" show Four "****" show Five "*****" Error: Error parse error on input data
Aucun commentaire:
Enregistrer un commentaire