[GHC] #10843: Allow do blocks without dollar signs as arguments

GHC ghc-devs at haskell.org
Mon Jul 4 08:04:42 UTC 2016


#10843: Allow do blocks without dollar signs as arguments
-------------------------------------+-------------------------------------
        Reporter:  agibiansky        |                Owner:  agibiansky
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.10.2
  (Parser)                           |
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #11706            |  Differential Rev(s):  Phab:D1219
       Wiki Page:                    |
-------------------------------------+-------------------------------------

@@ -46,0 +46,2 @@
+
+ Wiki page: [wiki:ArgumentDo]

New description:

 I would like the following to be valid Haskell code:

 {{{#!hs
 main = when True do
   putStrLn "Hello!"
 }}}

 Instead of requiring a dollar sign before the "do". This would parse as

 {{{#!hs
 main = when True (do
   putStrLn "Hello!")
 }}}


 Similarly, allow lambdas in the same way
 {{{#!hs
 main = forM values \value ->
   print value
 }}}

 parses as

 {{{#!hs
 main = forM values (\value ->
   print value)
 }}}

 One possible question: does this also do the same thing for LambdaCase? I
 think that since people expect lambda case to just be a simple desugaring
 it should also work, so then

 {{{#!hs
 main = forM values \case
     Just x -> print x
     Nothing -> print y
 }}}

 parses as

 {{{#!hs
 main = forM values (\case
     Just x -> print x
     Nothing -> print y)
 }}}

 Wiki page: [wiki:ArgumentDo]

--

Comment (by simonpj):

 Akio has made a wiki page to specify the feature: [wiki:ArgumentDo]

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


More information about the ghc-tickets mailing list