<div dir="ltr">Using RULES to simplify arrows in conjunction with proc-do notation doesn't seem feasible. (If i'm wrong, please tell me). The desugarer seems to use lambdas that can't be captured by RULES:<div><br></div><div><div> (\ ds_d9Aj -></div><div> let! { (a_a851, b_a852) ~ _ <- ds_d9Aj } in</div><div> ((a_a851, b_a852), ())))</div><div> or</div><div> (\ ds_d9Ai -> let! { (ds_d9Ag, _) ~ _ <- ds_d9Ai } in ds_d9Ag))</div><div>or</div><div> (\ ds_d9Ab -></div><div> let! { (a_a851, b_a852) ~ _ <- ds_d9Ab } in</div><div> (((a_a851, b_a852), ()), ())))</div></div><div><br></div><div>The constant shuffling of the tuples in comparison to the point-free arrow style also seems to make it harder to optimize. This change [1] is stalled at the moment and I'm also not sure how much it would help. Would using named functions allow one to use RULES? On the other hand, how can we obtain a better result without the tuple overhead? Does proc notation require it and can we obtain a better translation of proc to a point-free style?<br><br>[1](<a href="https://phabricator.haskell.org/D72">https://phabricator.haskell.org/D72</a>)<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Feb 21, 2015 at 5:39 AM, Ross Paterson <span dir="ltr"><<a href="mailto:R.Paterson@city.ac.uk" target="_blank">R.Paterson@city.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="">On Fri, Feb 20, 2015 at 02:58:14AM -0500, Thomas Bereknyei wrote:<br>
> I am looking at the proc notation de-sugar and I see results like this when<br>
> using a Free Arrow (mostly copied from [1]):<br>
> line2 = proc n -> do<br>
> Effect getURLSum *** Effect getURLSum -< n<br>
><br>
> Seq [Pure ] (Seq [Pure ] (Seq [Pure ] (Seq [Pure ](Par <Effect > {Effect } ) ) ) )<br>
><br>
> while this is so much simpler:<br>
> line2 = Effect getURLSum *** Effect getURLSum<br>
><br>
> Par <Effect > {Effect }<br>
><br>
> Those `Seq [Pure ]` sequences come from application of (.) and I have noticed<br>
> many similar inefficiencies in the Arrow preprocessor. Eventually the goal<br>
> would be to optimize when possible, for example I started looking into this in<br>
> order to use `concurrently` for (***) when in IO.<br>
><br>
> There was a rewrite mentioned here [2]. The deSugar/DsArrows.hs [3] looks<br>
> convoluted. Any progress or work needed? Or are Arrows not used much and not<br>
> worth the effort?<br>
<br>
</span>I don't think it's feasible to try to do optimization in the desugarer,<br>
which certainly is convoluted. You might have more luck using RULES to<br>
simplify the output.<br>
<br>
(The desugarer could be simplified -- a lot of what it does probably belongs<br>
in the renamer -- but I'm not sure that would help with optimization.)<br>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div><br></div></div>