[Haskell-cafe] "Assignment" in do blocks?

Francesco Ariis fa-ml at ariis.it
Thu Aug 27 14:39:10 UTC 2015


On Thu, Aug 27, 2015 at 06:51:57PM +0530, Anupam Jain wrote:
> How is this any worse than using `foo <- return $ bar foo` or `let foo
> = something completely unrelated`?

I happen to prefer

    foo  = something
    foo' = bar foo

to

    foo = something
    foo <- return $ bar foo

because if on line 147 I find `x = foo` then I have to scan the source
file (or function) only to the point where I find `foo`, while with
'reassignment'/shadowing this doesn't hold.

"The code from this point onwards shouldn't use foo but there is no way
to enforce that" is indeed an annoyance, which can only be awkwardly
expressed as:

    λ> (let a = 1 in 2) + a
    <interactive>:5:20: Not in scope: ‘a’

But don't mind me, I prefer to use `>>= \var ->` instead of do notation!

> > Time to add your proposal here!
> > https://wiki.haskell.org/Nitpicks
> 
> I just requested access to the wiki.

Thank you for taking time to add your proposal and peace be upon
William Yager for coming up with the List of Nitpicks, having them
in one place is a great way to assess the issues in an organic manner.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150827/d22f83cf/attachment.sig>


More information about the Haskell-Cafe mailing list