
#12490: With RebindableSyntax, ApplicativeDo should eliminate return/pure -------------------------------------+------------------------------------- Reporter: AaronFriel | Owner: simonmar Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: 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 AaronFriel): Please permit me some additional questions, I would like to know more about the compiler internals. I think I see why you might want to do this in the type checker, to make sure that `return` or `pure` has the right type before performing the transformation? If so, I don't know how important that is, but with `RebindableSyntax` and `ApplicativeDo` I would assume the user is saying, "I know what I'm doing and I want the transformation to be assumed to be lawful." And, as the `ApplicativeDo` desugaring will still contain `join` or `return` in many cases, incorrectly typed `pure` and `return` definitions ought to cause a compiler error sooner or later. Does that line up with your thoughts? When you say "`Name` of `return`", do you mean in case `return` has been aliased by the user? Does `Name` then correspond to what I would call the fully qualified name, e.g.: `Control.Monad.foo`? If I understand your solution correctly, will any top-level `return` or `pure` permit the desugaring I wrote? (Duplicated here.) {{{#!hs fPure m = do a <- m b <- m pure (a, b) -- to: fPure m = My.(<*>) (My.fmap (\a b -> (a, b)) m) m }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12490#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler