<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 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">glasgow-haskell-users@haskell.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





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

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