Why are we transpiling Haskell to JavaScript

Hello, Habr! Today we will explain why we are writing a frontend in Haskell and compiling it to JavaScript. Generally speaking, this process is called transpilation:







Transpilation is the process of converting an X program into an equivalent Y program. Unlike compilation, X and Y are at roughly the same level of abstraction.







Why is transpilation needed?



In general, there are two main purposes of transpilation:







  1. . , , . , , . - "" (deshugaring) . Babel, JS , . , , . , Python 2.x Python 3 2to3.
  2. , / . , JS ( ) WASM ( ), , . , , . , , ( ), . , (, SourceMap JS).


:







  • -, JS:



        — TypeScript — JavaScript , .

        — CoffeeScript — JS , Python Haskell.

        — Elm — ( Haskell), - , The Elm Architecture (TEA). 

        — PureScript — Haskell- .

        — ClojureScript — Clojure (, , ) - .
  • :



        — Bluespec — , Haskell, Verilog.

        — Clash — , Haskell , VHDL, Verilog SystemVerilog.

        — Verilator — , Verilog C++ SystemC.
  • (, 16- Intel 8086 8- Intel 8080).


JS?



, JS. , :







  • JS -.
  • , , , , ..
  • , - , .
  • . , - . , . - .
  • , , JSON . , , , .
  • API . , , , . , API, API , - . , . , API.
  • , , . . — "" , . , , .


JS



- :







  • .
  • Haskell.
  • Haskell.
  • .


Typeable - Haskell - Reflex (FRP). Haskell JavaScript GHCJS.







TypeScript JS - , , Haskell, .







Reflex Elm PureScript - , . , Reflex - "". Elm Reflex .









JS, :









, :







  • JS .
  • , . , .
  • JS.


:








All Articles