[Haskell-cafe] 'let' keyword optional in do notation?

Ertugrul Söylemez es at ertes.de
Wed Aug 8 17:27:56 CEST 2012

Vo Minh Thu <noteed at gmail.com> wrote:

> This is not a parsing problem, but a scoping one: try to run this
> program:
> main = do
>   let x = y
>       y = 5
>   let a = b
>   let b = 6
>   print (x, y, a, b)
> Cheers,
> Thu

Martijn has actually covered this question:

> > Where each sequence of let-less bindings is put in a separate
> > binding group. I'm no parsing wizard, but I couldn't come up with
> > any situations in which this would cause ambiguity. To me, the
> > let-less version is easier on the eyes, more consistent with <-
> > bindings, and also makes it less of a hassle to move stuff around.

The suggestion seems sound to me, and the additional 'let' can really be
annoying in cases where you have a lot of 'let' bindings among very few
monadic actions.  My current way to deal with this is to move the stuff
to separate computations, but it's certainly not a nice solution:

    myComp = c >>= f
        f x = ...
            a = ...
            b = ...


Not to be or to be and (not to be or to be and (not to be or to be and
(not to be or to be and ... that is the list monad.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120808/0980be7c/attachment.pgp>

More information about the Haskell-Cafe mailing list