Re: [Haskell-cafe] Couple of questions about *let* within *do*

On Tue, Aug 10, 2010 at 2:40 PM, Bill Atkins
They're not really statements, they're just named expressions and are still subject to lazy evaluation.
In:
let x = putStrLn "Name" >> getLine putStrLn "Welcome" x
Yes, 'putStrLn "name" >> getLine' is an expression. However, the whole line 'let x = putStrLn "Name" >> getLine' inside the do-block is an statement. Althought the word 'let' is used in both cases, they are defined in different places of the grammar (see the links of my previous mail). So when you write do ... let ... -- stmt ... you are using a let statement. You can use a let expression in a do-block as well: do ... let ... in ... -- expr ... Note, however, that you must indent the 'in' part, as you would need to indent an if expression inside a do-block. do ... do {... let ... -- expr gets parsed as ;let ... -- stmt in ... -- ;in ... -- ??? ... ;...} Cheers, -- Felipe.
participants (1)
-
Felipe Lessa