<div dir="ltr">Hi, George. Yes, please do add a task, hopefully to serve as a conversation anchor until the issues and path forward are clearer. From my perspective, class methods are among the most natural and useful candidates for rewrite rules, since they tend to have associated laws, many (but not all) of which are helpful in optimization. The alternative I know (and am using) is fairly inconvenient: replicating entire APIs just in order to delay inlining long enough to apply rules.<div><br></div><div>Thanks,  - Conal<br><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Dec 11, 2016 at 7:24 AM, George Colpitts <span dir="ltr"><<a href="mailto:george.colpitts@gmail.com" target="_blank">george.colpitts@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Do you want me to add a task ticket to remove this restriction that rewrite rules can't be used for class methods?<br><br><div class="gmail_quote"><div><div class="h5"><div dir="ltr">On Tue, Nov 22, 2016 at 8:06 AM Simon Peyton Jones via Glasgow-haskell-users <<a href="mailto:glasgow-haskell-users@haskell.org" target="_blank">glasgow-haskell-users@<wbr>haskell.org</a>> wrote:<br></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">





<div lang="EN-GB" link="blue" vlink="purple" class="m_-2678514581035961560gmail_msg">
<div class="m_-2678514581035961560m_-1969559206483650637WordSection1 m_-2678514581035961560gmail_msg">
<p class="MsoNormal m_-2678514581035961560gmail_msg"><span style="font-family:"Calibri",sans-serif" class="m_-2678514581035961560gmail_msg">Conal<u class="m_-2678514581035961560gmail_msg"></u><u class="m_-2678514581035961560gmail_msg"></u></span></p></div></div><div lang="EN-GB" link="blue" vlink="purple" class="m_-2678514581035961560gmail_msg"><div class="m_-2678514581035961560m_-1969559206483650637WordSection1 m_-2678514581035961560gmail_msg">
<p class="MsoNormal m_-2678514581035961560gmail_msg"><span style="font-family:"Calibri",sans-serif" class="m_-2678514581035961560gmail_msg"><u class="m_-2678514581035961560gmail_msg"></u> <u class="m_-2678514581035961560gmail_msg"></u></span></p>
<p class="MsoNormal m_-2678514581035961560gmail_msg" style="margin-left:36.0pt"><span style="font-size:13.5pt;color:black" class="m_-2678514581035961560gmail_msg">Is it possible to apply GHC rewrite rules to class methods?<u class="m_-2678514581035961560gmail_msg"></u><u class="m_-2678514581035961560gmail_msg"></u></span></p>
<p class="MsoNormal m_-2678514581035961560gmail_msg"><span style="font-family:"Calibri",sans-serif" class="m_-2678514581035961560gmail_msg"><u class="m_-2678514581035961560gmail_msg"></u> <u class="m_-2678514581035961560gmail_msg"></u></span></p>
</div></div><div lang="EN-GB" link="blue" vlink="purple" class="m_-2678514581035961560gmail_msg"><div class="m_-2678514581035961560m_-1969559206483650637WordSection1 m_-2678514581035961560gmail_msg"><p class="MsoNormal m_-2678514581035961560gmail_msg"><span style="font-family:"Calibri",sans-serif" class="m_-2678514581035961560gmail_msg">Not currently.  See
<a href="https://ghc.haskell.org/trac/ghc/ticket/11688" class="m_-2678514581035961560gmail_msg" target="_blank">https://ghc.haskell.org/trac/<wbr>ghc/ticket/11688</a>, esp comment:7 which gives links to similar examples. 
<a href="https://ghc.haskell.org/trac/ghc/ticket/10528" class="m_-2678514581035961560gmail_msg" target="_blank">https://ghc.haskell.org/trac/<wbr>ghc/ticket/10528</a> comment:13  gives more background.<u class="m_-2678514581035961560gmail_msg"></u><u class="m_-2678514581035961560gmail_msg"></u></span></p>
<p class="MsoNormal m_-2678514581035961560gmail_msg"><span style="font-family:"Calibri",sans-serif" class="m_-2678514581035961560gmail_msg"><u class="m_-2678514581035961560gmail_msg"></u> <u class="m_-2678514581035961560gmail_msg"></u></span></p>
<p class="MsoNormal m_-2678514581035961560gmail_msg"><span style="font-family:"Calibri",sans-serif" class="m_-2678514581035961560gmail_msg">It’d be great if someone wanted to think through all this.<u class="m_-2678514581035961560gmail_msg"></u><u class="m_-2678514581035961560gmail_msg"></u></span></p>
<p class="MsoNormal m_-2678514581035961560gmail_msg"><span style="font-family:"Calibri",sans-serif" class="m_-2678514581035961560gmail_msg"><u class="m_-2678514581035961560gmail_msg"></u> <u class="m_-2678514581035961560gmail_msg"></u></span></p>
<p class="MsoNormal m_-2678514581035961560gmail_msg"><span style="font-family:"Calibri",sans-serif" class="m_-2678514581035961560gmail_msg">Simon<u class="m_-2678514581035961560gmail_msg"></u><u class="m_-2678514581035961560gmail_msg"></u></span></p>
<p class="MsoNormal m_-2678514581035961560gmail_msg"><span style="font-family:"Calibri",sans-serif" class="m_-2678514581035961560gmail_msg"><u class="m_-2678514581035961560gmail_msg"></u> <u class="m_-2678514581035961560gmail_msg"></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt" class="m_-2678514581035961560gmail_msg">
<div class="m_-2678514581035961560gmail_msg">
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm" class="m_-2678514581035961560gmail_msg">
<p class="MsoNormal m_-2678514581035961560gmail_msg"><b class="m_-2678514581035961560gmail_msg"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif" class="m_-2678514581035961560gmail_msg">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif" class="m_-2678514581035961560gmail_msg"> Glasgow-haskell-users [mailto:<a href="mailto:glasgow-haskell-users-bounces@haskell.org" class="m_-2678514581035961560gmail_msg" target="_blank">glasgow-haskell-users-<wbr>bounces@haskell.org</a>]
<b class="m_-2678514581035961560gmail_msg">On Behalf Of </b>Conal Elliott<br class="m_-2678514581035961560gmail_msg">
<b class="m_-2678514581035961560gmail_msg">Sent:</b> 17 November 2016 16:40<br class="m_-2678514581035961560gmail_msg">
<b class="m_-2678514581035961560gmail_msg">To:</b> <a href="mailto:glasgow-haskell-users@haskell.org" class="m_-2678514581035961560gmail_msg" target="_blank">glasgow-haskell-users@haskell.<wbr>org</a><br class="m_-2678514581035961560gmail_msg">
<b class="m_-2678514581035961560gmail_msg">Subject:</b> GHC rewrite rules for class operations & laws<u class="m_-2678514581035961560gmail_msg"></u><u class="m_-2678514581035961560gmail_msg"></u></span></p>
</div>
</div></div></div></div><div lang="EN-GB" link="blue" vlink="purple" class="m_-2678514581035961560gmail_msg"><div class="m_-2678514581035961560m_-1969559206483650637WordSection1 m_-2678514581035961560gmail_msg"><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt" class="m_-2678514581035961560gmail_msg">
<p class="MsoNormal m_-2678514581035961560gmail_msg"><u class="m_-2678514581035961560gmail_msg"></u> <u class="m_-2678514581035961560gmail_msg"></u></p>
<div class="m_-2678514581035961560gmail_msg">
<p style="margin-bottom:12.0pt" class="m_-2678514581035961560gmail_msg"><span style="font-size:13.5pt;color:black" class="m_-2678514581035961560gmail_msg">Is it possible to apply GHC rewrite rules to class methods? From what I’ve read and seen, class methods get eliminated early by automatically-generated rules. Is there really no way
 to postpone such inlining until a later simplifier stage? The <a href="https://na01.safelinks.protection.outlook.com/?url=https:%2F%2Fdownloads.haskell.org%2F~ghc%2Flatest%2Fdocs%2Fhtml%2Fusers_guide%2Fglasgow_exts.html%23how-rules-interact-with-class-methods&data=02%7C01%7Csimonpj%40microsoft.com%7C8678611c4c57499f97be08d40f08662a%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636149976146128136&sdata=GjkFhlWdNkT6eo85FvcLKkJYoir7Dui9xJ9kMTYKVmU%3D&reserved=0" class="m_-2678514581035961560gmail_msg" target="_blank"><span style="color:#9999cc" class="m_-2678514581035961560gmail_msg">GHC
 Users Guide docs say no</span></a>, and suggests instead giving a duplicate vocabulary with somewhat awkward names for class methods. I’ve not seen this practice in libraries. I gather that we cannot therefore use class laws as optimizations in the form of
 rewrite rules, which seems a terrible loss. <u class="m_-2678514581035961560gmail_msg"></u><u class="m_-2678514581035961560gmail_msg"></u></span></p>
<p style="margin-bottom:12.0pt" class="m_-2678514581035961560gmail_msg"><span style="font-size:13.5pt;color:black" class="m_-2678514581035961560gmail_msg">In </span><span class="m_-2678514581035961560m_-1969559206483650637gmail-dt m_-2678514581035961560gmail_msg"><span style="font-size:14.5pt;font-family:"Courier New";color:#902000;border:none windowtext 1.0pt;padding:0cm" class="m_-2678514581035961560gmail_msg">Control.Category</span></span><span style="font-size:13.5pt;color:black" class="m_-2678514581035961560gmail_msg"> and </span><span class="m_-2678514581035961560m_-1969559206483650637gmail-dt m_-2678514581035961560gmail_msg"><span style="font-size:14.5pt;font-family:"Courier New";color:#902000;border:none windowtext 1.0pt;padding:0cm" class="m_-2678514581035961560gmail_msg">Contro<wbr>l.Arrow</span></span><span style="font-size:13.5pt;color:black" class="m_-2678514581035961560gmail_msg">,
 I see rules for class laws but also header comments saying “The RULES for the methods of class Arrow may never fire e.g. compose/arr; see Trac #10528”.<u class="m_-2678514581035961560gmail_msg"></u><u class="m_-2678514581035961560gmail_msg"></u></span></p>
<p style="margin-bottom:12.0pt" class="m_-2678514581035961560gmail_msg"><span style="font-size:13.5pt;color:black" class="m_-2678514581035961560gmail_msg">I’d appreciate a reality check about my conclusions as well as any strategies for using class laws in optimization.<u class="m_-2678514581035961560gmail_msg"></u><u class="m_-2678514581035961560gmail_msg"></u></span></p>
<p style="margin-bottom:12.0pt" class="m_-2678514581035961560gmail_msg"><span style="font-size:13.5pt;color:black" class="m_-2678514581035961560gmail_msg">Thanks, -- Conal<u class="m_-2678514581035961560gmail_msg"></u><u class="m_-2678514581035961560gmail_msg"></u></span></p>
</div>
</div></div></div></div></div>

______________________________<wbr>_________________<span class=""><br class="m_-2678514581035961560gmail_msg">
Glasgow-haskell-users mailing list<br class="m_-2678514581035961560gmail_msg">
<a href="mailto:Glasgow-haskell-users@haskell.org" class="m_-2678514581035961560gmail_msg" target="_blank">Glasgow-haskell-users@haskell.<wbr>org</a><br class="m_-2678514581035961560gmail_msg">
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users" rel="noreferrer" class="m_-2678514581035961560gmail_msg" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/glasgow-<wbr>haskell-users</a><br class="m_-2678514581035961560gmail_msg">
</span></blockquote></div></div>
</blockquote></div><br></div>