#4148: improve new recursive do syntax ---------------------------------+------------------------------------------ Reporter: guest | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 6.12.3 Keywords: | Difficulty: Os: Unknown/Multiple | Testcase: Architecture: Unknown/Multiple | Failure: None/Unknown ---------------------------------+------------------------------------------
Comment(by simonpj): I'm adding Ross's recent email to this ticket since it is relevant. http://www.haskell.org/pipermail/glasgow-haskell- users/2010-June/018944.html Here it is verbatim. There's also an underlying semantic issue, which is not yet resolved. The GHC implementation of mdo (following Levent and John's paper) performs a dependency analysis on the statements in the mdo to apply mfix to the shortest possible subsegments of statements. For example, {{{ mdo a <- f b b <- g b c <- h b d <- k d return d }}} is translated to the equivalent of {{{ do (a,b) <- mfix $ \ (a,b) -> do a <- f b b <- g b return (a,b) c <- h b d <- mfix $ \ d -> d <- k d return d return d }}} As the User's Guide notes, the choice of segments can change the semantics with some monads. When rec was added to GHC, the implementation used the same code and thus also did automatic segmentation. The original idea of rec (in arrow notation) was that it would give the programmer direct control over these segments: the loop/mfix combinators would go wherever the programmer put a rec, but I didn't realize Simon had done it the other way until he mentioned it last October. So: * if rec is to continue to do automatic segmentation, it might as well be a modifier on the do keyword (though this would break backward compatibility of arrow notation), * but I want to argue against automatic segmentation, because I don't think the compiler should be making subtle changes to the program's semantics on its own. It would simplify the compiler a bit too. -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4148#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler _______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs