[Haskell-cafe] Proposal: Non-recursive let
Richard A. O'Keefe
ok at cs.otago.ac.nz
Thu Jul 25 09:34:55 CEST 2013
On 25/07/2013, at 7:09 PM, <oleg at okmij.org> wrote:
> Here is a snippet from a real code that could benefit from
> non-recursive let.
[[A big blob of extremely dense code.]]
_Nothing_ is going to make that easy to read.
And I say that as someone who loves Haskell and is in *awe* of
Oleg. I mean, if the functional rain is pouring down and Oleg
says "Hey, sunny!", I normally furl my umbrella...
One of the things that I find makes it hard for _me_ to read
is the coding style where "do" is sneaked away out of sight.
Am I alone in wanting "do" at the _beginning_ of a line so
that it stands out? Do real Haskell experts just get used to
using "do" so much that they don't feel it's _worth_ making
It's a queer thing, I always feel that the advice about
keeping function bodies small is patronising nonsense for
beginners and that *my* code is perfectly readable no matter
how big it is, but end up wishing that *other* people kept
*their* functions small. It's not as if my code were bug-free...
Must be something in the water.
That's relevant though. If your functions are small, you don't
get enough "versions" of a variable for non-recursive let to pay off.
In this specific example, as a _reader_, a much less competent
reader than Oleg, the only problem I can see with using "ast1"
and "header1" is that th names are not different *ENOUGH* from
"ast1" and "header". I'd like names that go some towards
explaining *why* 'ast1' has "_token" and "_period_values" slots
that 'ast' doesn't (and for that matter, something a bit longer
than 'ast', which doesn't seem to stand for Abstract Syntax Tree
here), and *why* 'headers1' shouldn't include "_limit_to" and
"_limit_rcvd" slots unless there is a title.
All in all, a good example of code where using non-recursive let
would have DECREASED readability by one person strange to the code.
More information about the Haskell-Cafe