<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 1 Apr 2020 at 02:49, Alexis King <<a href="mailto:lexi.lambda@gmail.com">lexi.lambda@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><br><div>I’ve been trying to figure out if it would be possible to help the optimizer out by annotating the program with special combinators like the existing ones provided by GHC.Magic. However, I haven’t been able to come up with anything yet that seems like it would actually work.</div></div></blockquote><div><br></div><div>You may want to take a look at <a href="https://github.com/composewell/fusion-plugin">https://github.com/composewell/fusion-plugin</a> which uses annotations to help GHC fuse, not specifically what you want but might possibly be relevant to your work. <a href="https://github.com/composewell/streamly">https://github.com/composewell/streamly</a> relies heavily on case-of-case and SpecConstr for stream fusion. There are several cases that GHC is unable to fuse currently. We use a "Fuse" annotation to tell GHC that any function involving this type must be inlined so that fusion can occur reliably. With the help of fusion-plugin we have been able to fuse almost every known case in streamly till now.<br></div><div><br></div><div>-harendra<br> </div></div></div>