[Haskell-cafe] GHC Core / STG to supercombinators

Csaba Hruska csaba.hruska at gmail.com
Mon Apr 9 22:26:20 UTC 2018


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-L135

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 at 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 at 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.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180410/d0a8f853/attachment.html>


More information about the Haskell-Cafe mailing list