User gives: year, month, day, hour and minute and I would like to return CalendarTime value using these values. How can I do that - because I have error: 'Couldn't match expected type IO CalendarTime against inferred type Int'. What is wrong in function getDateTime ?
Proposition: all values are correct, for example month is from range 1 - 12 etc - I deleted validation from below code because otherwise code would be too long.
isInteger i = not (null i) && all isDigit i
getInteger :: String -> IO Int
getInteger q = do
putStr q;
i <- getLine
if isInteger i == False then do
putStrLn "Bad number"
getInt q
else return (read i)
getDateTime :: String -> IO CalendarTime
getDateTime question = do
putStr question;
year <- getInteger "Year: "
month <- getInteger "Month: "
day <- getInteger "Day: "
hour <- getInteger "Hour: "
minute <- getInteger "Minute: "
return CalendarTime(year month day hour minute 0)