[GHC] #13511: ApplicativeDo return case doesn't handle lets

GHC ghc-devs at haskell.org
Fri Feb 2 12:58:16 UTC 2018


#13511: ApplicativeDo return case doesn't handle lets
-------------------------------------+-------------------------------------
        Reporter:  mnislaih          |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  8.0.2
      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 chshersh):

 I experienced similar issue with `-XApplicativeDo` while using
 `-XRecordWildCards` and `optparse-applicative` library. What I wanted to
 write:

 {{{#!hs
 data Options = Options { reportTime :: Integer }

 optionsParser :: Parser Options
 optionsParser = do
     hours   <- option auto $ long "hours"
     minutes <- option auto $ long "minutes"
     let reportTime = hours * 60 + minutes
     pure Options{..}
 }}}

 What helped is to write it like this:

 {{{#!hs
 data Options = Options { reportTime :: Integer }

 optionsParser :: Parser Options
 optionsParser = do
     hours   <- option auto $ long "hours"
     minutes <- option auto $ long "minutes"
     pure Options{ reportTime = hours * 60 + minutes }
 }}}

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


More information about the ghc-tickets mailing list