<div dir="ltr">Hello,<br><br>I'd like to use GHC as a haskell frontend in a project.<br>I wonder what is the easiest way to compile Haskell to supercombinators (top level functions) using GHC as a library.<br><br>Is it possible to use the 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</li></ul>Regarding the eta expansion and lambda lifting it seems 
(according the comments in simplifier code) it does not guarantee to make these 
transformations in every case. <br><div><div><div><div><div><div>If GHC could transform the Core representation to supercombinators, which transformation should I use from <b>CoreToDo</b>?<br><a href="https://github.com/ghc/ghc/blob/master/compiler/simplCore/CoreMonad.hs#L107-L135" target="_blank">https://github.com/ghc/ghc/<wbr>blob/master/compiler/<wbr>simplCore/CoreMonad.hs#L107-<wbr>L135</a><br><br></div>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><div>Or would it be simpler to generate top level (lazy) functions from STG?<br></div><div><br></div>Regards,<br></div>Csaba Hruska<br></div>