I am trying to get a better grasp of the do statement and it's syntacs. So far I have come to understand from written material that x <- statement evaluates the statement-expression and assign it to x, whereas the let x = statement gives the statement a new name, x, without evaluating it first.
If that is the case how come this works:
fmap_int f g =
do
toInt <- getLine
let x = read toInt :: Integer
let y = fmap f g x
return y
when this doesn't work:
fmap_int2 f g =
do
toInt <- getLine
let x = read toInt :: Integer
y <- fmap f g x
return y