One more 'do' pattern

Thomas Davie tom.davie at gmail.com
Sat Mar 28 05:05:02 EDT 2009


On 28 Mar 2009, at 09:54, Bulat Ziganshin wrote:

> Hello haskell-prime,
>
> as we know, the following code
>
> action x y >>= \v -> do
>
> can be shortened to following
>
> v <- action x y
>
>
>
> but there is one more very popular 'do' pattern, with a 'do' block
> passed as a parameter:
>
> for list $ \element -> do
>  ...
>
> or
>
> bracket createDialog destroyDialog $ \dialog -> do
> ...
>
>
> what about adding one more 'do' sugar that will allow to move
> variable name to the left, such as
>
> for element in list do
> or
> with dialog in bracket createDialog destroyDialog do
>
> or just
>
> element <-- for list do
> dialog <-- bracket createDialog destroyDialog do
>
> ?

In all honesty, I find the idea of adding yet more "imperative"  
looking stuff to do notation an appalling idea.  We already get  
problems because people read do notation and think it means "execute  
this in sequence" (see threads about lazy IO not doing what's expected  
for example).

As an aside, while these are merely syntactic sugars, I find the idea  
of attacking the problem with syntax to be somewhat silly as well.   
This simply adds a special syntax for another couple of cases that  
crop up occasionally.  What do we do when we have another, and  
another, and another, do we keep just adding more and more syntax?

Bob



More information about the Haskell-prime mailing list