Haskell 2020: 'let' to be optional and with wider scope of visibility, like other Haskell functions

Sven Panne svenpanne at gmail.com
Sun Apr 16 15:10:22 UTC 2017


2017-04-16 14:37 GMT+02:00 Vassil Ognyanov Keremidchiev <varosi at gmail.com>:

> A small proposition for the next standard.
>

I think every proposal should clearly state the problem it is trying to
solve first, because only after there's some agreement that it is actually
a problem, further discussion is useful.


> 1) It is to lower verbosity with omitting 'let' keyword in do-notation and
> use only (=) for describing let/pure blocks. [...]
>

As has been discussed quite a few times on this and other Haskell-related
lists, "verbosity" is a very subjective measure, and the number of
characters to type is one of the worst metrics for evaluating the
usefulness of a feature.

In our example at hand, "let" is a very useful syntactic cue, and the
visual difference between "x = foo" and "x <- foo" is a bit low IMHO. One
can probably remove a lot of other syntactic stuff from Haskell and still
keep it parsable by machines, but I think that's a non-goal. Remember that
e.g. the entropy of English text is around 1 bit per character, but we
don't speak binary, for a good reason. :-)

2) Second proposition is every pure expression ('let') in do-block to have
> visibility in whole block, just like top-level function is visible in whole
> module. Currently there is difference in visibility depending on that if a
> function is in do-block or is outside it.
>

I think the difference is there for a good reason: The desugaring rules are
easy to comprehend. With your proposal things get complicated. Take e.g. a
slightly modified version of your example (which can easily be complicated
much more by alternating the different forms of bindings):


> main = do
>      z <- action x
>      x = expression1 y
>      y = expression2 z
>
>      putStrLn (x ++ y ++ z)
>

What is the meaning of this? And what problem exactly is this part of the
proposal trying to solve?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-prime/attachments/20170416/dc65df7a/attachment.html>


More information about the Haskell-prime mailing list