https://doi.org/10.71352/ac.36.117
Compiling Haskell to JavaScript through Clean's core
Abstract.
Crossing the borders of languages by letting them cooperate on source code level has enormous benefits as different languages have
distinct language features and useful libraries to share. This is particularly true for the functional programming world,
where languages are in constant development being the target of active research. There already exists a double-edged compiler
frontend for the lazy functional languages Haskell and Clean, which enables the interoperation of features of both languages.
This paper presents a program transformation technique to solve the same problem at another level by transforming STG,
the core language of the flagship Haskell compiler GHC to SAPL, the core language of Clean. By this transformation
(1) we have made a Haskell to JavaScript compiler with the advantage that Haskell applications can now be executed e.g. in a browser;
(2) since there already existed a Clean to JavaScript compiler, under certain limitations, one can mix Clean and Haskell code because
they are compiled to the same target code using the same run-time system and calling convention;
(3) one can more easily compare the core code generated by the two compilers and measure their execution times.
