[Haskell-cafe] extending Do notation

Kim-Ee Yeoh ky3 at atamo.com
Tue May 20 16:08:34 UTC 2014


On Tue, May 20, 2014 at 9:27 PM, silvio <silvio.frischi at gmail.com> wrote:

> >     4) res <- fmap pureFunction ioFunction === let res = pureFunction {
> >     ioFunction}
> >
> >
> > From a distance, let and monadic bind are just different forms of name
> > binding.
> >
> > But haskell's let has an effectlessness that makes it declaratively
> > different from its cousin in, say, ocaml.
> >
> > This is no small change you're proposing.
>
> You might have misunderstood. The 'let' in the do notation is already
> different from the normal 'let' in that it doesn't have an 'in' for
> example. {} should of course only work inside a do block.


But you know about the desugaring for let statements within do blocks, yes?

There's nothing magical about let. Which is to say, there's a regularity
about let that current haskell allows us to take for granted. What you're
proposing makes the let in a do-block different from a let 'in' a do-block,
braces notwithstanding i.e.

do
   let ... { ... }

vs

do
   let ... in

So to return to this:

>     4) res <- fmap pureFunction ioFunction === let res = pureFunction {
>     ioFunction}

If res in "let res = ..." is not referred to anywhere in the do-block
created by desugaring, it's as if the let didn't exist.

On the other hand, for "res <- ... ioFunction", the effect of ioFunction is
realized regardless of whether res is referenced.

-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140520/446df760/attachment.html>


More information about the Haskell-Cafe mailing list