
#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: | Differential Revisions: Phab:D1219 -------------------------------------+------------------------------------- Changes (by simonpj): * differential: => Phab:D1219 Comment: I'm not against this, but not wildly in favour either. It might be convenient, but it's another small wrinkle. Some thoughts * Haskell allows {{{ f MkT { x = 3 } y z }}} meaning {{{ f (MkT {x = 3}) y z }}} which I have always thought of as a bit of a mistake. The former looks (to my eye) too much like a function call with four argument. However, you could argue that the `do` version is less harmful, because the initial `do` signals the start of a `do` block, whereas the initial `MkT` could be a bare constructor argument. * What do you intend for {{{ f x do { blarg } y z }}} Is that equivalent to this? {{{ f x (do { blarg }) y z }}} If so, better to say so. * Also give an example with layout. So perhaps {{{ f x do p <- ps return (p+1) z z }}} is equivalent to {{{ f x (do { p <- ps; return (p+1) }) y z }}} I think lambda-case is similar. * Lambda is different because it does not start implicit layout. So perhaps an un-parenthesised lambda can only appear as the last argument. Better say so. * If you allow lambda, why not `if`? And I suppose `case`? {{{ f x if this then that else the_other }}} means {{{ f x (if this then that else the_other }}} I suspect that this is a bridge too far, but I think it poses no more parsing difficulty than Lambda. Right? * What about infix functions? I.e. is this ok? {{{ f >>> do blarg }}} Presumably the `do` binds more tightly than any operator? I suggest that you make a wiki page on the GHC Trac to describe the extension, along with examples to cover these corner cases, and advertise it on the ghc-users list. That might elicit some info about whether people would find this useful or not. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10843#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler