[Haskell-cafe] Let's teach GHC idiom brackets!
ollie at ocharles.org.uk
Thu Feb 19 09:36:17 UTC 2015
Bas van Dijk <v.dijk.bas at gmail.com> writes:
> Do we still need idiom brackets if we have ApplicativeDo?
I think they solve different things. ApplicativeDo is a nice extension
when I need to run n different effectful computations, but either use
m < n results (that is, emulating the <* and *> operators), and/or if I
need to return the results in a different order.
do a <- x
b <- y
c <- z
That's going to be a pain to write using idiom brackets:
(| (\a b _ -> (b, a)) x y z |)
However, for the common case where you do want to apply a function to
the result of all effectful computations, then ApplicativeDo just forces
you to introduce new symbol names:
do x' <- x
y' <- y
z' <- z
f x' y' z'
I'm against this not just due to the extra amount of typing, but
choosing names is often an unnecessary cognitive burden - I've often
already used up the "obvious" name, and now I'm forced to come up with
another set of names, unless I want to live with shadowing warnings (not
an option, I use -Werror).
More information about the Haskell-Cafe