Hello, I wonder what is the easiest way to compile Haskell to supercombinators (top level functions) using GHC as a library. Is it possible to use GHC simplifier to transform the parsed Haskell source to supercombinators? i.e. to do - eta expansion - closure conversion - lambda lifting Or should it be written from scratch? Is Core or STG suited better for this purpose? Thanks, Csaba
Hi Csaba, 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 https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/extending_gh... 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. Regards, Shao Cheng On Tue, Apr 10, 2018 at 2:51 AM, Csaba Hruska <csaba.hruska@gmail.com> wrote:
Hello,
I wonder what is the easiest way to compile Haskell to supercombinators (top level functions) using GHC as a library.
Is it possible to use GHC simplifier to transform the parsed Haskell source to supercombinators? i.e. to do
- eta expansion - closure conversion - lambda lifting
Or should it be written from scratch?
Is Core or STG suited better for this purpose?
Thanks, Csaba
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
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. If GHC can transform the Core representation to supercombinators, which transformation sould I use from *CoreToDo*? https://github.com/ghc/ghc/blob/master/compiler/simplCore/CoreMonad.hs#L107-... Maybe I should give more details: I'd like to use GHC as a frontend for my custom code generator which can handle (lazy) top level functions only. Is it better to use GHC as a library or is it better to write a compiler plugin to capture the core representation. I do not want to optimize the Core at all neither want to use other parts of GHC's backend (i.e. codegen). Ideally GHC would typecheck and transform everything to top level function and my system would do the rest. Do you know what would be the easiest way to do this? (i.e. via *CoreToDo* or custom calls for the simplifying functions) Regards, Csaba Hruska On Mon, Apr 9, 2018 at 9:11 PM, Shao Cheng <astrohavoc@gmail.com> wrote:
Hi Csaba,
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 https://downloads.haskell.org/~ghc/latest/docs/html/users_ guide/extending_ghc.html#compiler-plugins
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.
Regards, Shao Cheng
On Tue, Apr 10, 2018 at 2:51 AM, Csaba Hruska <csaba.hruska@gmail.com> wrote:
Hello,
I wonder what is the easiest way to compile Haskell to supercombinators (top level functions) using GHC as a library.
Is it possible to use GHC simplifier to transform the parsed Haskell source to supercombinators? i.e. to do
- eta expansion - closure conversion - lambda lifting
Or should it be written from scratch?
Is Core or STG suited better for this purpose?
Thanks, Csaba
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
participants (2)
-
Csaba Hruska -
Shao Cheng