<div dir="ltr"><div><div><div><div><div><div><div>I've checked the source code of GHC's simplifier. Regarding the eta expansion and lambda lifting it seems (according the comments) it does not guarantee to make these transformations in every case. <br></div>If GHC can transform the Core representation to supercombinators, which transformation sould I use from <b>CoreToDo</b>?<br><a href="https://github.com/ghc/ghc/blob/master/compiler/simplCore/CoreMonad.hs#L107-L135">https://github.com/ghc/ghc/blob/master/compiler/simplCore/CoreMonad.hs#L107-L135</a><br><br></div>Maybe I should give more details:<br>I'd like to use GHC as a frontend for my custom code generator which can handle (lazy) top level functions only.<br></div>Is it better to use GHC as a library or is it better to write a compiler plugin to capture the core representation.<br></div>I do not want to optimize the Core at all neither want to use other parts of GHC's backend (i.e. codegen).<br>Ideally GHC would typecheck and transform everything to top level function and my system would do the rest.<br><br></div>Do you know what would be the easiest way to do this? (i.e. via <b>CoreToDo</b> or custom calls for the simplifying functions)<br><br></div>Regards,<br></div>Csaba Hruska<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 9, 2018 at 9:11 PM, Shao Cheng <span dir="ltr"><<a href="mailto:astrohavoc@gmail.com" target="_blank">astrohavoc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi Csaba,</div><div><br></div><div>The transformations you described already exist as core simplifier passes. For custom compilation, you may write your own pass using the core plugin mechanism, see <a href="https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/extending_ghc.html#compiler-plugins" target="_blank">https://downloads.haskell.org/<wbr>~ghc/latest/docs/html/users_<wbr>guide/extending_ghc.html#<wbr>compiler-plugins</a><br></div><div><br></div><div>It's also possible to perform transformations on STG, but it takes extra effort to retrieve/transform the in-memory STG representations, and type safety is also not guaranteed.<br></div><div><br></div><div>Regards,</div><div>Shao Cheng<br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Tue, Apr 10, 2018 at 2:51 AM, Csaba Hruska <span dir="ltr"><<a href="mailto:csaba.hruska@gmail.com" target="_blank">csaba.hruska@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div><div><div><div><div>Hello,<br><br></div>I wonder what is the easiest way to compile Haskell to supercombinators (top level functions) using GHC as a library.<br><br></div>Is it possible to use GHC simplifier to transform the parsed Haskell source to supercombinators? i.e. to do<br><ul><li>eta expansion</li><li>closure conversion</li><li>lambda lifting<br></li></ul>Or should it be written from scratch?<br></div><br>Is Core or STG suited better for this purpose?<br><br></div>Thanks,<br></div>Csaba<br></div>
<br></div></div>______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/haskell-caf<wbr>e</a><br>
Only members subscribed via the mailman list are allowed to post.<br></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/haskell-<wbr>cafe</a><br>
Only members subscribed via the mailman list are allowed to post.<br></blockquote></div><br></div>