[GHC] #11835: ApplicativeDo failed to desugar last line with pure $ <expr>

GHC ghc-devs at haskell.org
Fri Jun 17 11:39:22 UTC 2016


#11835: ApplicativeDo failed to desugar last line with pure $ <expr>
-------------------------------------+-------------------------------------
        Reporter:  Cosmia            |                Owner:  simonmar
            Type:  bug               |               Status:  merge
        Priority:  normal            |            Milestone:  8.0.2
       Component:  Compiler          |              Version:  8.0.1-rc2
      Resolution:                    |             Keywords:  ApplicativeDo
Operating System:  MacOS X           |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #11607            |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonmar):

 GHC translates

 {{{
 do x <- e
    return (f x)
 }}}

 into

 {{{
 (\x -> f x) <$> e
 }}}

 So we have to spot `return`, because the transformation removes it.  You
 could invent more rules, say spot `return $ e` for example, but there
 would always be more examples that you couldn't handle, it's not possible
 to be completely general here.

 Consider `return` (or `pure`) as part of the syntax of the `do`
 expression, like a keyword.  Maybe if we were starting from scratch the
 syntax would be different.  Indeed, in Monad Comprehensions, the `return`
 is always there implicitly.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11835#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list