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

GHC ghc-devs at haskell.org
Fri Jul 15 21:26:11 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:                    |
-------------------------------------+-------------------------------------

Comment (by Iceland_jack):

 The recent
 [https://github.com/koengit/KeyMonad/blob/9bcf22d3f5fb08ff0bfb6b6db7c179d8675df520/paper.lhs
 ''Key'' monad] lets us mimic Arrow notation in user code

 {{{#!hs
 -- addA :: Arrow a => a b Int -> a b Int -> a b Int
 -- addA f g = proc $ \z -> do
 --     x <- f -< z
 --     y <- g -< z
 --     return $ (+) <$> x <*> y
 addA :: Arrow a => a b Int -> a b Int -> a b Int
 addA f g = proc \z -> do
     x <- f -< z
     y <- g -< z
     return $ (+) <$> x <*> y
 }}}

 compared to

 {{{#!hs
 addA :: Arrow a => a b Int -> a b Int -> a b Int
 addA f g = procb z -> do
    x <- f -< z
    y <- g -< z
    returnA -< x + y
 }}}

 ----

 In an alternative universe with idiom brackets

 {{{#!hs
 addA :: Arrow a => a b Int -> a b Int -> a b Int
 addA f g = proc \z -> do
     x <- f -< z
     y <- g -< z
     return [| x + y |]
 }}}

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


More information about the ghc-tickets mailing list