<div dir="ltr">Thanks, Simon. For now, I've added a module with aliases for all of my class methods and law-based rewrite rules in terms of those aliases.<div><br></div><div>- Conal</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 22, 2016 at 4:06 AM, Simon Peyton Jones <span dir="ltr"><<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>></span> wrote:<br><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">
<div class="m_4886773790463420029WordSection1">
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif">Conal<u></u><u></u></span></p><span class="">
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:13.5pt;color:black">Is it possible to apply GHC rewrite rules to class methods?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif"><u></u> <u></u></span></p>
</span><p class="MsoNormal"><span style="font-family:"Calibri",sans-serif">Not currently. See
<a href="https://ghc.haskell.org/trac/ghc/ticket/11688" 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" target="_blank">https://ghc.haskell.org/trac/<wbr>ghc/ticket/10528</a> comment:13 gives more background.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif">It’d be great if someone wanted to think through all this.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif">Simon<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri",sans-serif"><u></u> <u></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Glasgow-haskell-users [mailto:<a href="mailto:glasgow-haskell-users-bounces@haskell.org" target="_blank">glasgow-haskell-users-<wbr>bounces@haskell.org</a>]
<b>On Behalf Of </b>Conal Elliott<br>
<b>Sent:</b> 17 November 2016 16:40<br>
<b>To:</b> <a href="mailto:glasgow-haskell-users@haskell.org" target="_blank">glasgow-haskell-users@haskell.<wbr>org</a><br>
<b>Subject:</b> GHC rewrite rules for class operations & laws<u></u><u></u></span></p>
</div>
</div><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p style="margin-bottom:12.0pt"><span style="font-size:13.5pt;color:black">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" target="_blank"><span style="color:#9999cc">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></u><u></u></span></p>
<p style="margin-bottom:12.0pt"><span style="font-size:13.5pt;color:black">In </span><span class="m_4886773790463420029gmail-dt"><span style="font-size:14.5pt;font-family:"Courier New";color:#902000;border:none windowtext 1.0pt;padding:0cm">Control.Category</span></span><span style="font-size:13.5pt;color:black"> and </span><span class="m_4886773790463420029gmail-dt"><span style="font-size:14.5pt;font-family:"Courier New";color:#902000;border:none windowtext 1.0pt;padding:0cm">Contro<wbr>l.Arrow</span></span><span style="font-size:13.5pt;color:black">,
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></u><u></u></span></p>
<p style="margin-bottom:12.0pt"><span style="font-size:13.5pt;color:black">I’d appreciate a reality check about my conclusions as well as any strategies for using class laws in optimization.<u></u><u></u></span></p>
<p style="margin-bottom:12.0pt"><span style="font-size:13.5pt;color:black">Thanks, -- Conal<u></u><u></u></span></p>
</div>
</div></div></div>
</div>
</div>
</blockquote></div><br></div>