
#10892: ApplicativeDo should use *> and <* -------------------------------------+------------------------------------- Reporter: simonmar | Owner: bollu Type: task | Status: new Priority: high | Milestone: 8.4.1 Component: Compiler | Version: 7.11 Resolution: | Keywords: ApplicativeDo Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: 12143 Related Tickets: #13309 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by AaronFriel): @ekmett, @simonpj, @bgamari I am working on this issue and have a preliminary patch that explores the design space for this. For the exploring implementation, I added a new constructor of `ApplicativeArg`, `ApplicativeArgNil`, which lacks a pattern. To explore the design space and verify my type checking, I modified the renamer to use `<$` and `<*` (in place of `fmap` and `<*>`) if and only if every statement in the segment was an `ApplicativeArgNil`: {{{#!hs mkApplicativeStmt ctxt args need_join body_stmts | all isAppArgNil args = do { (replace_op, fvs1) <- lookupStmtName ctxt replaceFName ; (but_op, fvs2) <- lookupStmtName ctxt butAName ... }}} For the sake of faithfully implementing your proposed desugaring, I need to ask about this: {{{#!hs -- Example: f = do foo;bar;baz; x <- quux; y <- quaffle; return (xyzzy x y) -- Desugaring: f' = foo *> bar *> baz *> (xyzzy <$> quux <*> quaffle) }}} Is there a reason that desugaring is strictly better than: {{{#!hs -- Desugaring: f'' = xyzzy <$> (foo *> bar *> baz *> quux) <*> quaffle }}} I don't think it'd be too difficult to move the `*>` "then" operators to the beginning, but it would involve changing more of the existing applicative code to do so. I think that this style is more suited to addressing #13309. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10892#comment:19 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler