<div dir="ltr">Hello, fellow workers!<div><br></div><div>So, I'll pop in here with my thoughts.<div><br></div><div>I'm writing an independent intermediate language library for functional languages, and I looked at using Hoopl. I would use it, but there are several reasons why I'm not currently doing so:</div><div><br></div><div>1) Combining facts from different domains through fancy lattice algorithms. This is fairly straightforward to add to Hoopl with minimal extra API change.  <br></div><div><br></div><div>2) I wanted to write my data facts as a type-level list, `freer-effects` style, in order to be more explicit in my types about dependencies between analyses. This would require significantly altering the API.</div><div><br></div><div>3) Its own custom graph code. This is the biggest reason why I decided not to. Some problems: </div><div>  * It seems impossible to change the topology of the graph in a rewriting step.</div><div>  * I wanted to use term hypergraphs/hyperjungles due to some pretty nifty properties</div><div>  * The intermediate language I'm implementing, a derivative of Graph Reduction Intermediate Notation, aka GRIN from UHC, is, as its name implies, intrinsically graph-based. Thus, graph manipulation has to be pretty easy to do.</div><div><br></div><div>So instead, I've decided to optimise another hypergraph library (`graph-rewriting` - I'm going to be rewriting it to use an inductive representation a la FGL)  and implement a generic, Hoopl-esque analysis library on top of that. (Or more accurately, that is my plan for the next six months - I've been sidetracked getting parsing to work nice with an effect-based stack!)</div><div><br></div><div>So, if Hoopl2 does become a thing, I'd be very keen on working on it, but if I were to actually use it myself, it'd probably require a complete rewrite. Fortunately, it's a pretty small library; and for GHC, its current usage is a pretty straightforward usecase which shouldn't be affected too much. That being said, if GHC were to better use Hoopl (e.g. moving some of the optimisations on Core to be Hoopl-based passes) then it would be a different story.</div><div><br></div><div>So I guess I'm volunteering to do the rewrite for a potential Hoopl2 if it's wanted, as I'm about to do pretty much that anyway.</div><div><br></div><div>Cheers,</div><div>Sophie</div><div><br></div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, 9 Jun 2017 at 22:31 Michal Terepeta <<a href="mailto:michal.terepeta@gmail.com">michal.terepeta@gmail.com</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"><div><div>> On Fri, Jun 9, 2017 at 9:50 AM Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>> wrote:<br></div><div>> > Maybe this is the core of our disagreement - why is it a good idea to have Hoopl as a separate package in the first place?</div><div>></div><div>>  </div><div>> One reason only: because it makes Hoopl usable by compilers other than GHC.  And, dually, efforts by others to improve Hoopl will benefit GHC.</div><div>>  </div><div>> > If I proposed extracting parts of Core optimizer to a separate package, wouldn't you expect some really good reasons for doing this?</div><div>></div><div>>  </div><div>> A re-usable library should be</div><div>> a)      a significant chunk of code,</div><div>> b)      that can plausibly be re-purposed by others</div><div>> c)      and that has an explicable API</div><div>>  </div><div>> I think the Core optimiser is so big, and so GHC specific, that (b) and (c) are unlikely to hold.  But we carefully designed Hoopl from the ground up so that it was agnostic about the node types, and so can be re-used for control flow graphs of many kinds.  It’s designed to be re-usable.  Whether it is actually re-used is another matter, of course.  But if it’s part of GHC, it can’t be.</div><div><br></div></div></div><div dir="ltr"><div><div>I agree with your characterization of a re-usable library and that</div><div>Core optimizer would not be a good fit. But I do think that Hoopl also</div><div>has some problems with b) and c) (although smaller):</div><div>- Using an optimizer-as-a-library is not really common (I'm not aware</div><div>  of any compilers doing this, LLVM is to some degree close but it</div><div>  exposes the whole language as the interface so it's closer to the</div><div>  idea of extracting the whole Cmm backend). So I don't think the API</div><div>  for such a project is well understood.</div><div>- The API is pretty wide and does put serious constraints on the IR</div><div>  (after all it defines blocks and graphs), making reusability</div><div>  potentially more tricky.</div><div><br></div><div>So I think I understand your argument and we just disagree on whether</div><div>this is worth the effort of having a separate package.</div><div><br></div><div>>  </div><div>> [...]</div></div></div><div dir="ltr"><div><div>>  </div><div>> > I've pointed multiple reasons why I think it has a significant cost.</div><div>></div><div>> Can you just summarise them again briefly for me?  If we are free to choose nomenclature and API for hoopl2, I’m not yet seeing why making it a separate package is harder than not doing so. E.g. template-haskell is a separate package.</div><div><br></div></div></div><div dir="ltr"><div><div>Having even Hoopl2 as a separate package would still entail</div><div>additional work:</div><div>- Hoopl2 would still need to duplicate some concepts (eg, `Unique`,</div><div>  etc. since it needs to be standalone)</div><div>- Understanding code (esp. by newcommers) would be harder: the Cmm</div><div>  backend would be split between GHC and Hoopl2, with the latter</div><div>  necessarily being far more general/polymorphic than needed by GHC.</div><div>- Getting the right performance in the presence of all this additional</div><div>  generality/polymorphism will likely require fair amount of</div><div>  additional work.</div><div>- If Hoopl2 is used by other compilers, then we need to be more</div><div>  careful changing anything in incompatible ways, this will require</div><div>  more discussions & release coordination.</div><div><br></div><div>Considering that Hoopl was never actually picked up by other</div><div>compilers, I'm not convinced that this cost is justified. But I</div><div>understand that other people might have a different opinion.</div><div>So how about a compromise:</div><div>- decouple GHC from the current Hoopl (ie, go ahead with my diff),</div><div>- keep everything Hoopl related only in `compiler/cmm/Hoopl` with the</div><div>  long-term intention of creating a separate package,</div><div>- experiment with and improve the code,</div><div>- once (if?) we're happy with the results, discuss what/how to</div><div>  extract to a separate package.</div><div>That gives us the freedom to try things out and see what works well</div><div>(I simply don't have ready solutions for anything, being able to</div><div>experiment is IMHO quite important). And once we reach the right</div><div>performance/representation/abstraction/API we can work on extracting</div><div>that.</div><div><br></div><div>What do you think?</div><div><br></div><div>Cheers,</div><div>Michal<br></div></div><div><br></div></div>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div>