<div dir="ltr">I'd like to propose a GHC extension called (for now) `ArgumentBody`. `ArgumentBody` is a simple syntax extension, than, when enabled, permits the following code:<div><br></div><div><pre style="margin-top:0px;margin-bottom:0px;overflow:auto;color:rgb(0,0,0);font-size:13px;background-image:initial;background-repeat:initial"><span class="" style="color:rgb(153,0,0);font-weight:bold">main</span> <span class="" style="font-weight:bold">=</span> when <span class="" style="color:rgb(68,85,136);font-weight:bold">True</span> <span class="" style="font-weight:bold">do</span>
putStrLn <span class="" style="color:rgb(187,136,68)">"Hello!"</span></pre><pre style="margin-top:0px;margin-bottom:0px;overflow:auto;color:rgb(0,0,0);font-size:13px;background-image:initial;background-repeat:initial"><span class="" style="color:rgb(187,136,68)"><br></span></pre><pre style="margin-top:0px;margin-bottom:0px;overflow:auto;color:rgb(0,0,0);font-size:13px;background-image:initial;background-repeat:initial"><span class="" style="color:rgb(187,136,68)"><pre style="margin-top:0px;margin-bottom:0px;overflow:auto;color:rgb(0,0,0);background-image:initial;background-repeat:initial"><span class="" style="color:rgb(153,0,0);font-weight:bold">main</span> <span class="" style="font-weight:bold">=</span> forM values <span class="" style="color:rgb(153,0,0);font-weight:bold">\</span>value <span class="" style="font-weight:bold">-></span>
print value</pre><pre style="margin-top:0px;margin-bottom:0px;overflow:auto;color:rgb(0,0,0);background-image:initial;background-repeat:initial"><br></pre><pre style="margin-top:0px;margin-bottom:0px;overflow:auto;color:rgb(0,0,0);background-image:initial;background-repeat:initial"><pre style="margin-top:0px;margin-bottom:0px;overflow:auto;background-image:initial;background-repeat:initial"><span class="" style="color:rgb(153,0,0);font-weight:bold">main</span> <span class="" style="font-weight:bold">=</span> forM values <span class="" style="color:rgb(153,0,0);font-weight:bold">\</span><span class="" style="font-weight:bold">case</span>
<span class="" style="color:rgb(68,85,136);font-weight:bold">Just</span> x <span class="" style="font-weight:bold">-></span> print x
<span class="" style="color:rgb(68,85,136);font-weight:bold">Nothing</span> <span class="" style="font-weight:bold">-></span> print y</pre></pre></span></pre><div><br></div><div>In this code we do not need `$` before `do`, lambda, or lambda-case (if -XLambdaCase is enabled). This change would <i>not</i> extend to `let`, `if`, `case`, or any other constructs.</div><div><br></div><div>Pros:</div><div><br></div><div>1. Code is simpler and it greatly reduces the need for "operator line noise" of $ everywhere.</div><div>2. We can avoid using the <a href="http://stackoverflow.com/questions/9468963/runst-and-function-composition">type-checker hack for $</a> for things such as runSt.</div><div><br></div><div>Cons:</div><div><br></div><div>1. Adds complexity to the compiler. (NB: The change is minimal and not invasive at all.)</div><div>2. Contributes to a proliferation of extensions that other tools must support. (NB: This is just a parser change so should be easy for all tools to support.)</div><div><br></div><div>I'm very interested in hearing both favoring and dissenting opinions on this proposed change. If this change is approved of, names besides -XArgumentBody can be considered.</div><div><br></div><div>See more info <a href="https://ghc.haskell.org/trac/ghc/ticket/10843#ticket">on Trac</a>.</div></div><div><br></div><div>-- Andrew Gibiansky</div></div>