• simonpj@microsoft.com's avatar
    Add 'rec' to stmts in a 'do', and deprecate 'mdo' · f04dead9
    simonpj@microsoft.com authored
    The change is this (see Trac #2798).  Instead of writing
    
      mdo { a <- getChar
          ; b <- f c
          ; c <- g b
          ; putChar c
          ; return b }
    
    you would write
    
      do { a <- getChar
         ; rec { b <- f c
               ; c <- g b }
         ; putChar c
         ; return b }
    
    That is, 
      * 'mdo' is eliminated 
      * 'rec' is added, which groups a bunch of statements
        into a single recursive statement
    
    This 'rec' thing is already present for the arrow notation, so it  
    makes the two more uniform.  Moreover, 'rec' lets you say more
    precisely where the recursion is (if you want to), whereas 'mdo' just
    says "there's recursion here somewhere".  Lastly, all this works with
    rebindable syntax (which mdo does not).
    
    Currently 'mdo' is enabled by -XRecursiveDo.  So we now deprecate this
    flag, with another flag -XDoRec to enable the 'rec' keyword.
    
    Implementation notes:
      * Some changes in Lexer.x
      * All uses of RecStmt now use record syntax
    
    I'm still not really happy with the "rec_ids" and "later_ids" in the
    RecStmt constructor, but I don't dare change it without consulting Ross
    about the consequences for arrow syntax.
    f04dead9
HsExpr.lhs 44.7 KB