michael rice nowgate at yahoo.com
Tue Aug 10 14:01:28 EDT 2010

```Hi all,

Thanks. I think I've got it. It nice to have come far enough with this to be thinking about how the pieces fit together. One more question:

Since

do s1
s2
let x1 = e1
x2 = e2
s3
s4

becomes

do s1
s2
let x1 = e1
x2 = e2 in do s3
s4

Then,

do s1
s2
let x1 = e1
x2 = e2
s3
s4
let x3 = e3
x4 = e4
s5
s6

becomes

do s1
s2
let x1 = e1
x2 = e2 in do s3
s4
let x3 = e3
x4 = e4 in do s5
s6?

Michael

--- On Tue, 8/10/10, Tillmann Rendel <rendel at Mathematik.Uni-Marburg.de> wrote:

From: Tillmann Rendel <rendel at Mathematik.Uni-Marburg.de>
To: "michael rice" <nowgate at yahoo.com>
Date: Tuesday, August 10, 2010, 1:35 PM

michael rice wrote:
> OK, then there's also an implicit *in* after the *let* in this code.

If you want to understand let statements in terms of let ... in ... expressions, you can do the following transformation:

do s1
s2
let x1 = e1
x2 = e2
s3
s4

becomes

do s1
s2
let x1 = e1
x2 = e2 in do s3
s4

So in a sense, there is an implicit "in do".

> Must the implicit (or explicit) *in* actually use the calculated value(s)?

No.

By the way, note that lazy evaluation applies, so the expressions bound in the let may or may not be evaluated, depending on the rest of the program.

> And, the monad can "continue on" after the *let* (with or without the *in*) as below, i.e., the *let* needn't be the last statement in the *do*?

Yes, there can be more statements after the let statement. In fact, the let statement must not be the last statement in the do-expression, because a do-expression has to end with an expression statement. Otherwise, what would the result of the do-expression be?

Tillmann

-------------- next part --------------
An HTML attachment was scrubbed...