<div dir="ltr">Done: <a href="https://ghc.haskell.org/trac/ghc/ticket/13044#ticket">https://ghc.haskell.org/trac/ghc/ticket/13044#ticket</a><div><br></div><div>Not sure if it fully captures what you want so people should feel free to edit.</div><div><br></div><div>Cheers</div><div>George</div><div><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Dec 28, 2016 at 8:27 PM Conal Elliott <<a href="mailto:conal@conal.net">conal@conal.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">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 class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Thanks,  - Conal<br class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div></div></div><div class="gmail_extra gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg">On Sun, Dec 11, 2016 at 7:24 AM, George Colpitts <span dir="ltr" class="gmail_msg"><<a href="mailto:george.colpitts@gmail.com" class="gmail_msg" target="_blank">george.colpitts@gmail.com</a>></span> wrote:<br class="gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">Do you want me to add a task ticket to remove this restriction that rewrite rules can't be used for class methods?<br class="gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg"><div class="m_-1043473217755130184h5 gmail_msg"><div dir="ltr" class="gmail_msg">On Tue, Nov 22, 2016 at 8:06 AM Simon Peyton Jones via Glasgow-haskell-users <<a href="mailto:glasgow-haskell-users@haskell.org" class="gmail_msg" target="_blank">glasgow-haskell-users@haskell.org</a>> wrote:<br class="gmail_msg"></div></div></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_msg"><div class="m_-1043473217755130184h5 gmail_msg">





<div lang="EN-GB" link="blue" vlink="purple" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">
<div class="m_-1043473217755130184m_-2678514581035961560m_-1969559206483650637WordSection1 m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">
<p class="MsoNormal m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><span style="font-family:"Calibri",sans-serif" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">Conal<u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u><u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u></span></p></div></div><div lang="EN-GB" link="blue" vlink="purple" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><div class="m_-1043473217755130184m_-2678514581035961560m_-1969559206483650637WordSection1 m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">
<p class="MsoNormal m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><span style="font-family:"Calibri",sans-serif" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u> <u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u></span></p>
<p class="MsoNormal m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg" style="margin-left:36.0pt"><span style="font-size:13.5pt;color:black" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">Is it possible to apply GHC rewrite rules to class methods?<u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u><u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u></span></p>
<p class="MsoNormal m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><span style="font-family:"Calibri",sans-serif" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u> <u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u></span></p>
</div></div><div lang="EN-GB" link="blue" vlink="purple" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><div class="m_-1043473217755130184m_-2678514581035961560m_-1969559206483650637WordSection1 m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><p class="MsoNormal m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><span style="font-family:"Calibri",sans-serif" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">Not currently.  See
<a href="https://ghc.haskell.org/trac/ghc/ticket/11688" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg" target="_blank">https://ghc.haskell.org/trac/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_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg" target="_blank">https://ghc.haskell.org/trac/ghc/ticket/10528</a> comment:13  gives more background.<u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u><u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u></span></p>
<p class="MsoNormal m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><span style="font-family:"Calibri",sans-serif" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u> <u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u></span></p>
<p class="MsoNormal m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><span style="font-family:"Calibri",sans-serif" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">It’d be great if someone wanted to think through all this.<u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u><u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u></span></p>
<p class="MsoNormal m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><span style="font-family:"Calibri",sans-serif" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u> <u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u></span></p>
<p class="MsoNormal m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><span style="font-family:"Calibri",sans-serif" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">Simon<u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u><u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u></span></p>
<p class="MsoNormal m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><span style="font-family:"Calibri",sans-serif" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u> <u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">
<div class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">
<p class="MsoNormal m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><b class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"> Glasgow-haskell-users [mailto:<a href="mailto:glasgow-haskell-users-bounces@haskell.org" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg" target="_blank">glasgow-haskell-users-bounces@haskell.org</a>]
<b class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">On Behalf Of </b>Conal Elliott<br class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">
<b class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">Sent:</b> 17 November 2016 16:40<br class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">
<b class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">To:</b> <a href="mailto:glasgow-haskell-users@haskell.org" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg" target="_blank">glasgow-haskell-users@haskell.org</a><br class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">
<b class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">Subject:</b> GHC rewrite rules for class operations & laws<u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u><u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u></span></p>
</div>
</div></div></div></div><div lang="EN-GB" link="blue" vlink="purple" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><div class="m_-1043473217755130184m_-2678514581035961560m_-1969559206483650637WordSection1 m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">
<p class="MsoNormal m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u> <u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u></p>
<div class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">
<p style="margin-bottom:12.0pt" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><span style="font-size:13.5pt;color:black" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_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_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg" target="_blank"><span style="color:#9999cc" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_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_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u><u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u></span></p>
<p style="margin-bottom:12.0pt" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><span style="font-size:13.5pt;color:black" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">In </span><span class="m_-1043473217755130184m_-2678514581035961560m_-1969559206483650637gmail-dt m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><span style="font-size:14.5pt;font-family:"Courier New";color:#902000;border:none windowtext 1.0pt;padding:0cm" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">Control.Category</span></span><span style="font-size:13.5pt;color:black" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"> and </span><span class="m_-1043473217755130184m_-2678514581035961560m_-1969559206483650637gmail-dt m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><span style="font-size:14.5pt;font-family:"Courier New";color:#902000;border:none windowtext 1.0pt;padding:0cm" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">Control.Arrow</span></span><span style="font-size:13.5pt;color:black" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_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_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u><u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u></span></p>
<p style="margin-bottom:12.0pt" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><span style="font-size:13.5pt;color:black" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">I’d appreciate a reality check about my conclusions as well as any strategies for using class laws in optimization.<u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u><u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u></span></p>
<p style="margin-bottom:12.0pt" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"><span style="font-size:13.5pt;color:black" class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg">Thanks, -- Conal<u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u><u class="m_-1043473217755130184m_-2678514581035961560gmail_msg gmail_msg"></u></span></p>
</div>
</div></div></div></div></div>

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