So, I want to rewrite the given prog
function with using >>
/>>=
bindings instead of do
and <-
:
prog :: IO Int
prog =
do putStrLn "Hello there! How old are you?"
age <- (readLn :: IO Int)
let agedays = show $ age * 365
putStrLn $ "So you are at least than " ++ agedays ++ " days old."
return (read agedays)
Rewriting more simple functions is not a problem for me, but the readLn :: IO Int
is giving me a headache...
My suggestion was:
prog :: IO Int
prog =
putStrLn "Hello there!How old are you?" >>
readLn::IO >>=
let agedays = \age -> show $ age * 365 >>
putStrLn $ "So you are at least than " ++ agedays ++ " days old."
However this just does not work, as there is a problem with binding the readLn :: IO
to the next anonymous function \age
. Any help?