[Haskell-cafe] Couple of questions about *let* within *do*
wren ng thornton
wren at freegeek.org
Tue Aug 10 15:17:31 EDT 2010
michael rice wrote:
> OK, then there's also an implicit *in* after the *let* in this code. Must the implicit (or explicit) *in* actually use the calculated value(s)?
>
> 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*?
>
More specifically, there is an implicit "in do". So given some code,
foo = do
something
let x = bar
y = baz
thingsome
somesome
First there's the insertion of braces and semicolons implied by the
layout rules.
foo = do
{ something
; let { x = bar
; y = baz
}; thingsome
; somesome
}
Then we desugar the let-do notation,
foo = do
{ something
; let { x = bar
; y = baz
} in do
{ thingsome
; somesome
}}
Or with prettier typesetting,
foo = do
{ something
; let
{ x = bar
; y = baz
} in do
{ thingsome
; somesome
}
}
and finally we can desugar do notation into (>>=), (>>), and fail.
--
Live well,
~wren
More information about the Haskell-Cafe
mailing list