[GHC] #15100: `ApplicativeDo` needlessly uses `join` too much

#15100: `ApplicativeDo` needlessly uses `join` too much -------------------------------------+------------------------------------- Reporter: ekmett | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.2 (CodeGen) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- {{{#!hs foo = do A 1 B 2 C 3 return () }}} produces very different code than {{{#!hs foo = do A 1 B 2 C 3 }}} for no good reason. Currently we check to see if the last clause is a `return` or something else, and then bolt a `join` in if it isn't `return`. But this check is too conservative. If it isn't a `return` but doesn't reference any of the variables above, you can still desugar it with `(<*>)`. We found this during a twitch livestream in front of an audience of 127 people. =) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15100 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15100: `ApplicativeDo` needlessly uses `join` too much -------------------------------------+------------------------------------- Reporter: ekmett | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.2 (CodeGen) | Resolution: | Keywords: ApplicativeDo Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by adamse): * keywords: => ApplicativeDo -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15100#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15100: `ApplicativeDo` needlessly uses `join` too much -------------------------------------+------------------------------------- Reporter: ekmett | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.2 (CodeGen) | Resolution: | Keywords: ApplicativeDo Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by dfeuer): This is all around `stmtTreeToStmts` in `compiler/rename/RnExpr`, and `needJoin` seems rather relevant. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15100#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15100: `ApplicativeDo` needlessly uses `join` too much -------------------------------------+------------------------------------- Reporter: ekmett | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.2 (CodeGen) | Resolution: | Keywords: ApplicativeDo Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * cc: dfeuer (added) Comment: Another thing that should work doesn't quite: {{{#!hs foo a b c = do a b res <- c return res }}} This is even more surprising, because it desugars without `join` (and without `>>=`), but with `>>`! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15100#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15100: `ApplicativeDo` needlessly uses `join` too much -------------------------------------+------------------------------------- Reporter: ekmett | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.2 (CodeGen) | Resolution: | Keywords: ApplicativeDo Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * cc: simonmar (added) Comment: cc'ing Simon Marlow, the king of `ApplicativeDo`. Whatever emerges, I'd love to see it expressed in the language of the paper. I found the division in the paper (into a dependency analysis followed by desugaring) to be very helpful. If we could have a typeset appendix that gives the ''actual'' rules followed by GHC (including improvements described above) that would be incredibly helpful. Both for understanding the code, and for helping others who implement `ApplicativeDo` in their compilers. We can easily make the paper source code available. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15100#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC