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:
- . , , . , , . - "" (deshugaring) . Babel, JS , . , ,
- , / . , 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, :
- , "" .
- : API, -, . , .
-
servant
, API , , , , API ( — ). - JSON, CSV, .. . API .
, :
- JS .
- , . , .
- JS.