10 Sep
2004
10 Sep
'04
10:50 p.m.
--- Stephan Zaubzer wrote: data Entry a = EmptyEntry | MakeEntry a a showEntry :: (Show a) => Entry a -> String showEntry EmptyEntry = "Empty" showEntry MakeEntry a b = show a ++ ": " ++ show b --- end of quote --- That's a good start. All you need to do now is make Entry an instance of the Show class:
instance (Show a) => Show (Entry a) where show = showEntry
Also, you have a small syntax error in showEntry - you probably want:
showEntry (MakeEntry a b) = show a ++ ": " ++ show b
Finally, using ShowS is generally better for this kind of thing. <http://www.haskell.org/tutorial/stdclasses.html> describes the disadvantages of using repeated appends and the advantages of ShowS. Hope that helps! /gXm
8021
Age (days ago)
8021
Last active (days ago)
0 comments
1 participants
participants (1)
-
J.Garrett.Morris@Dartmouth.EDU