
8 Aug
2011
8 Aug
'11
11:43 a.m.
On Mon, Aug 8, 2011 at 2:39 PM, Sunil S Nandihalli
Hello everybody, All I want to do in the following code is to read an integer from stdin and print it back to stdout. Can somebody help me fix my code snippet below.. Thanks, Sunil
module Main where import Prelude stringToInt::String->Int stringToInt str = read str main = do x<-getLine y<-stringToInt x print y
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
The code is *almost* right. You just need to change the second to last line to be: let y = stringToInt x Hoping someone else steps in with a good, beginner-friendly explanation of *why*. Michael