[GHC] #13875: ApplicativeDo desugaring is lazier than standard desugaring

GHC ghc-devs at haskell.org
Mon Jun 26 03:00:03 UTC 2017


#13875: ApplicativeDo desugaring is lazier than standard desugaring
-------------------------------------+-------------------------------------
           Reporter:  dfeuer         |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  8.4.1
          Component:  Compiler       |           Version:  8.3
           Keywords:  ApplicativeDo  |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  Other
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Suppose I write

 {{{#!hs
 import Data.Maybe (isJust)

 bangy m = do
   (_,_) <- m
   return ()

 main = print $ isJust (bangy (Just undefined))
 }}}

 If I compile this with `ApplicativeDo`, it prints `True`. Otherwise, it
 throws an exception. The basic problem is that the (correct) `bangy`
 function ''requires'' a `Monad` constraint, but `ApplicativeDo` replaces
 it with a lazier function that can get by with `Functor`. I believe it
 should desugar correctly, and impose a `Monad` constraint here. To get the
 `Functor` constraint should require an explicit lazy pattern match:

 {{{#!hs
 bangy m = do
   ~(_,_) <- m
   return ()
 }}}

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


More information about the ghc-tickets mailing list