<br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Alberto G. Corona</b> <span dir="ltr">&lt;<a href="mailto:agocorona@gmail.com">agocorona@gmail.com</a>&gt;</span><br>

Date: 2011/9/5<br>Subject: Re: [Haskell-cafe] Smarter do notation<br>To: Sebastian Fischer &lt;<a href="mailto:fischer@nii.ac.jp">fischer@nii.ac.jp</a>&gt;<br>Cc: Max Bolingbroke &lt;<a href="mailto:batterseapower@hotmail.com">batterseapower@hotmail.com</a>&gt;, <a href="mailto:haskell-cafe@haskell.org">haskell-cafe@haskell.org</a><br>

<br><br><div>The problem in the parallel distribution of monadic computations that may have been Applicative seems to be the &gt;&gt; operator</div><div><br></div><div>But if  Monad is defined as a subclass of applicative:</div>

<div>
<br></div><a href="http://www.haskell.org/haskellwiki/Functor-Applicative-Monad_Proposal" target="_blank">http://www.haskell.org/haskellwiki/Functor-Applicative-Monad_Proposal</a><div><br></div><div>then &quot;&gt;&gt;&quot; can be defined as   (&gt;&gt;) =   (*&gt;)  and parallelization should be pòssible ?</div>


<div><br></div><div><font color="#888888">Alberto<br><br></font><div class="gmail_quote"><div><div></div><div class="h5">2011/9/5 Sebastian Fischer <span dir="ltr">&lt;<a href="mailto:fischer@nii.ac.jp" target="_blank">fischer@nii.ac.jp</a>&gt;</span><br>

</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div class="h5">
Hi again,<div><br></div><div>I think the following rules capture what Max&#39;s program does if applied after the usual desugaring of do-notation:</div><div><br></div><div><div>a &gt;&gt;= \p -&gt; return b</div><div> --&gt;</div>



<div>(\p -&gt; b) &lt;$&gt; a</div><div><br></div><div>a &gt;&gt;= \p -&gt; f &lt;$&gt; b -- &#39;free p&#39; and &#39;free b&#39; disjoint</div><div> --&gt;</div><div>((\p -&gt; f) &lt;$&gt; a) &lt;*&gt; b</div><div><br>



</div><div>a &gt;&gt;= \p -&gt; f &lt;$&gt; b -- &#39;free p&#39; and &#39;free f&#39; disjoint</div><div> --&gt;</div><div>f &lt;$&gt; (a &gt;&gt;= \p -&gt; b)</div><div><br></div><div>a &gt;&gt;= \p -&gt; b &lt;*&gt; c -- &#39;free p&#39; and &#39;free c&#39; disjoint</div>



<div> --&gt;</div><div>(a &gt;&gt;= \p -&gt; b) &lt;*&gt; c</div><div><br></div><div>a &gt;&gt;= \p -&gt; b &gt;&gt;= \q -&gt; c -- &#39;free p&#39; and &#39;free b&#39; disjoint</div><div> --&gt;</div><div>liftA2 (,) a b &gt;&gt;= \(p,q) -&gt; c</div>



<div><br></div><div>a &gt;&gt;= \p -&gt; b &gt;&gt; c -- &#39;free p&#39; and &#39;free b&#39; disjoint</div><div> --&gt;</div><div>(a &lt;&lt; b) &gt;&gt;= \p -&gt; c</div><div><br></div><div>The second and third rule overlap and should be applied in this order. &#39;free&#39; gives all free variables of a pattern &#39;p&#39; or an expression &#39;a&#39;,&#39;b&#39;,&#39;c&#39;, or &#39;f&#39;.</div>



<div><br></div><div>If return, &gt;&gt;, and &lt;&lt; are defined in Applicative, I think the rules also achieve the minimal necessary class constraint for Thomas&#39;s examples that do not involve aliasing of return.</div>



<div><br></div><font color="#888888"><div>Sebastian</div></font><div><div></div><div><br><div class="gmail_quote">On Mon, Sep 5, 2011 at 5:37 PM, Sebastian Fischer <span dir="ltr">&lt;<a href="mailto:fischer@nii.ac.jp" target="_blank">fischer@nii.ac.jp</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Max, <div><br></div><div>thanks for you proposal!<br><br><div class="gmail_quote"><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Using the Applicative methods to optimise &quot;do&quot; desugaring is still</div>





possible, it&#39;s just not that easy to have that weaken the generated<br>
constraint from Monad to Applicative since only degenerate programs<br>
like this one won&#39;t use a Monad method:<br></blockquote><div><br></div></div><div>Is this still true, once Monad is a subclass of Applicative which defines return?</div><div><br></div><div>I&#39;d still somewhat prefer if return get&#39;s merged with the preceding statement so sometimes only a Functor constraint is generated but I think, I should adjust your desugaring then..</div>




<div><br></div><font color="#888888"><div>Sebastian</div></font></div><br></div>
</blockquote></div><br></div></div></div>
<br></div></div><div class="im">_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></div></blockquote></div><br></div>
</div><br>