haskell - How to use a specific constructor from a datatype while there are multiple possible type constructor -
i have following data types , create instance of sport don't know how call type football data type sport.
`data football = football { players :: players , stadium :: stadium } data tennis = tennis { players1 :: players , stadium1 :: stadium } data sport = sf football | st tennis when do:
instance show => show (sport a) show football{..} = "<== football ==>" show tennis{..} = "<== tennis ==>" i error message: couldn't match expected type ‘sport a’ actual type ‘football t6’ tryed other ways , check other example figure out how it... 1 have idea?
thanks in advance :)
you need parentheses here
data sport = sf (football a) | st (tennis a) then need pattern match against sports, not other types:
instance show => show (sport a) show (sf football{..}) = "<== football ==>" show (st tennis{..}) = "<== tennis ==>"
Comments
Post a Comment