What's with the 'in' keyword?

Viewed 4924

In Haskell, why do you not use 'in' with 'let' inside of a do-block, but you must otherwise?

For example, in the somewhat contrived examples below:

afunc :: Int -> Int
afunc a = 
       let x = 9 in
       a * x

amfunc :: IO Int -> IO Int
amfunc a = do
       let x = 9
       a' <- a
       return (a' * x)

It's an easy enough rule to remember, but I just don't understand the reason for it.

3 Answers
Related