[Haskell-beginners] Re: Non-recursive binding expression

Brent Yorgey byorgey at seas.upenn.edu
Sat Feb 28 19:10:47 EST 2009


On Sat, Feb 28, 2009 at 10:31:37PM +0000, Will Ness wrote:
> 
> That's what I understood the OP wanted - Scheme's LET, not LETREC, allowing for 
> shadowing. I was suprised let-statement in do chain didn't work that way. I 
> expected it to be equivalent to a kind of code above, since each new line in do 
> block represents a nested function in explicit bind notation, and nested 
> function binding definitely provides for non-recursive let kind of argument 
> binding, with shadowing. 
> 
> I thought the whole point of having special let statement in do notation was 
> not to have to write the kind of code above with singleton lists. Since we have 
> shadowing there, it should've been so in let-statements too. Isn't it?

No, the point of let expressions in do-blocks is to have a convenient
way to make pure bindings, i.e. ones that aren't piped through >>= .
Note that let statements in do-blocks just get desugared into normal
let expressions:

  do { let x = y ; stuff }
  
    desugars into

  let x = y in do { stuff }

Haskell simply doesn't have anything equivalent to Scheme's LET,
except for actual nested functions.

-Brent


More information about the Beginners mailing list