I am taking input from the user and the code is as follows:
putStrLn $ "Enter number"
num <- getLine
main = print $ num
When I run this code, the compiler gives following error:
ra.hs:10:5: parse error on input `<-'
How can I remove this error? I have tried to use spaces, as well as tab characters, but the error persists. Please help.
You have to move all of your code into main
The area outside of main is for declarations, etc. You use
<-
inside of ado
.Also, you don't need the extra
$
's when there is a single parameter.