Why can't you use substitution inside a do block? This code works fine.
test :: (x -> x) -> [x] -> [x]
test f a = map f a
main :: IO ()
main = do
let sq x = x * x :: Int
let ret = test sq [1,2,3]
print ret
But if you remove the let's inside the do block, I got compile errors.
parse error on input ‘=’
Perhaps you need a 'let' in a 'do' block?
e.g. 'let x = 5' instead of 'x = 5'
Is "let x = y" equivalent to "x <- y" inside a do block? So if the right hand side returns a IO something, you need to use let's (or <-) ? I know it's a dummy question but I always get compile error with this. eii