Yeah, I use SHE and her idiom brackets for several of my projects, but there are many cases in which they&#39;re awkward too.<div><br></div><div>Another consideration about the &quot;monad&quot; comprehensions is that unbound (i.e., with no &lt;-) statements in a monad comprehension are treated as MonadPlus guards, so the applicative &lt;* and *&gt; wouldn&#39;t really have a clean place to go.<br>
<br><div class="gmail_quote">On Sun, Sep 4, 2011 at 1:32 PM, Dominique Devriese <span dir="ltr">&lt;<a href="mailto:dominique.devriese@cs.kuleuven.be">dominique.devriese@cs.kuleuven.be</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
It&#39;s not the same as what you propose, but it&#39;s related, so for<br>
discussion, I just want to point out idiom brackets (an analog for<br>
do-notation for Applicative functors) which have been introduced in<br>
some Haskell-related languages. Examples are Idris<br>
(<a href="http://www.cs.st-andrews.ac.uk/~eb/Idris/donotation.html" target="_blank">http://www.cs.st-andrews.ac.uk/~eb/Idris/donotation.html</a>) and SHE<br>
(<a href="http://personal.cis.strath.ac.uk/~conor/pub/she/idiom.html" target="_blank">http://personal.cis.strath.ac.uk/~conor/pub/she/idiom.html</a>).<br>
<br>
Dominique<br>
<br>
2011/9/4 Daniel Peebles &lt;<a href="mailto:pumpkingod@gmail.com">pumpkingod@gmail.com</a>&gt;:<br>
<div><div></div><div class="h5">&gt; Hi all,<br>
&gt; I was wondering what people thought of a smarter do notation. Currently,<br>
&gt; there&#39;s an almost trivial desugaring of do notation into (&gt;&gt;=), (&gt;&gt;), and<br>
&gt; fail (grr!) which seem to naturally imply Monads (although oddly enough,<br>
&gt; return is never used in the desugaring). The simplicity of the desugaring is<br>
&gt; nice, but in many cases people write monadic code that could easily have<br>
&gt; been Applicative.<br>
&gt; For example, if I write in a do block:<br>
&gt; x &lt;- action1<br>
&gt; y &lt;- action2<br>
&gt; z &lt;- action3<br>
&gt; return (f x y z)<br>
&gt; that doesn&#39;t require any of the context-sensitivty that Monads give you, and<br>
&gt; could be processed a lot more efficiently by a clever Applicative instance<br>
&gt; (a parser, for instance). Furthermore, if return values are ignored, we<br>
&gt; could use the (&lt;$), (&lt;*), or (*&gt;) operators which could make the whole thing<br>
&gt; even more efficient in some instances.<br>
&gt; Of course, the fact that the return method is explicitly mentioned in my<br>
&gt; example suggests that unless we do some real voodoo, Applicative would have<br>
&gt; to be a superclass of Monad for this to make sense. But with the new default<br>
&gt; superclass instances people are talking about in GHC, that doesn&#39;t seem too<br>
&gt; unlikely in the near future.<br>
&gt; On the implementation side, it seems fairly straightforward to determine<br>
&gt; whether Applicative is enough for a given do block. Does anyone have any<br>
&gt; opinions on whether this would be a worthwhile change? The downsides seem to<br>
&gt; be a more complex desugaring pass (although still something most people<br>
&gt; could perform in their heads), and some instability with making small<br>
&gt; changes to the code in a do block. If you make a small change to use a<br>
&gt; variable before the return, you instantly jump from Applicative to Monad and<br>
&gt; might break types in your program. I&#39;m not convinced that&#39;s necessary a bad<br>
&gt; thing, though.<br>
&gt; Any thoughts?<br>
&gt; Thanks,<br>
&gt; Dan<br>
</div></div><div><div></div><div class="h5">&gt; _______________________________________________<br>
&gt; Haskell-Cafe mailing list<br>
&gt; <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
&gt; <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br></div>