haskell-issues
haskell-issues copied to clipboard
do notation: Traversal sugar
In place of any last line of a do block reading foo $ \x -> do
, you should be able to write something like x <-- foo
and continue in the same do block. (Perhaps only as long as you stay in the same monad?)
The primary use case I'm thinking of is i <-- forM [1..10]
, but arbitrary traversals also suggest themselves. One might also want versions for different arities, for cases like sequence $ do
or indexed traversals.
(I actually like it that I have to indent the body of a for_
loop, though.)
What about \x <- foo
instead, by the way?
<--
should not preserve the lambda symbol: Neither does <-
.
(Note x <- foo
= x <-- (>>=) foo
.)