Jump to content

User Input: Difference between revisions

m
m (Moved to Text and Basic learning cats)
Line 165:
str <- getLine
putStr "Enter an integer: "
num <- getLine >>= return.readreadLn :: IO Int
putStrLn $ str ++ (show num)
Note: <tt>:: IO Int</tt> is only there to disambiguate what type we wanted from <tt>read</tt>. If <tt>num</tt> were used in a numerical context, its type would have been inferred by the interpreter/compiler.
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.