[Haskell-cafe] new recursive do notation (ghc 6.12.x) spoils layout

Alexander Solla ajs at 2piix.com
Sun Jun 20 21:24:54 EDT 2010


On Jun 21, 2010, at 10:18 AM, John Lask wrote:

>  do rec
>    a <- getChar
>    b <- f c
>    c <- g b
>    putChar c
>    return b
>
> I don't particularly care that the only recursive statements are  
> #2,#3 - I just want my nice neat layout back. I have just spent an  
> inordinate amount of time updating code when if the parser  
> recognised "do rec" as a recursive group it would have been a drop  
> in replacement and taken me one tenth of the time.
>
> Why can't we have this?

Why can't you just use let notation do deal with the recursion?  I  
thought "lets" in do blocks were just a little bit of syntactic sugar  
for "regular" let expressions, which do allow mutual recursion.  I  
could be totally wrong though.  I'm thinking of something like:

do a <- getChar
    let b = c >>= return . f
    let c = b >>= return . g
    c >>= putChar
    b
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100620/7fab1249/attachment.html


More information about the Haskell-Cafe mailing list