I’m new to Haskell and I’m trying to write a simple program. However, when running the following program:
main = do
args <- getArgs
let w = read (args !! 0) :: Integer
in print w
I get this error message:
file.hs:4:5: parse error on input `in'
The same let syntax works just fine outside of a do statement...
What am I doing wrong?
The let syntax is different when inside a do block. You don't need the in part, the variable scope is automatically the rest of the do block.
In your case:
main = do
args <- getArgs
let w = read (args !! 0) :: Integer
print w
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With