
Am Freitag 12 Februar 2010 20:15:26 schrieb kane96@gmx.de:
the exercise looks like that:
readMyCal :: IO MyCalendar readMyCal = do putStr "day: " d <- readInt putStr "month: " m <- readMonth putStr "year: " y <- readInt let mydate = (d,m,y) if not (legalDate mydate) then do putStrLn "wrong" --COMPLETE-1-- else --COMPLETE-2--
COMPLETE-1: the user can give in a new date. I did it by simple calling the function again
Reasonable.
COMPLETE-2: the user can choose if he wants to enter a new. If not, all dates the user has put in should be put out as a calendar (a list of dates)
Okay, that's not nice. But since you have no global variables to store the list of dates entered in (yes, there are ways to have global variables, but it's not a good idea unless you really have to), call readMoreDates :: [MyDate] -> IO MyCaledar readMoreDates previous = do ... (code duplication where it isn't really necessary, but what the heck).