Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/angerman/haskell-to-web
Haskell to Web compilation Experiments
https://github.com/angerman/haskell-to-web
Last synced: 14 days ago
JSON representation
Haskell to Web compilation Experiments
- Host: GitHub
- URL: https://github.com/angerman/haskell-to-web
- Owner: angerman
- Created: 2019-01-08T14:23:01.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-04-01T10:03:46.000Z (almost 6 years ago)
- Last Synced: 2024-11-14T02:02:57.589Z (about 2 months ago)
- Size: 11.5 MB
- Stars: 11
- Watchers: 4
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.org
Awesome Lists containing this project
README
* Haskell to Web compilation survey
There are three haskell to web compilers in varying maturity levels.
- [[https://github.com/ghcjs/ghcjs][ghcjs]] the oldest haskell to web compiler that produces JavaScript.
- [[https://github.com/tweag/asterius][Asterius]] a haskell to webassembly compiler.
- [[https://github.com/WebGHC][WebGHC]] a webassembly code generator for ghc.** Building
Please refer to the relevant notes regarding building of the
compilers.| | Linux | macOS | Windows |
| ghcjs | Yes | Yes | |
| Asterius | Yes | No | |
| WebGHC | Yes | Yes | |Notes: [[ghcjs-build-notes.org][ghcjs]] [[webghc-build-notes.org][WebGHC]]
** Features
** Compiling applications / libraries
*** ghcjs
**** building
#+BEGIN_SRC bash
cabal new-build --project-file=ghcjs.project --ghcjs exe:$app -fexamples --allow-newer
#+END_SRC**** optimizing
One option is to pass ~-dedupe~, which should reduce the resulting
size. The other is to use googles closure compiler to optimize it.It turns out that sometimes ~-dedupe~ will increase the size, but
make the result more favorable to the googles closure compiler.#+BEGIN_SRC bash
ccjs all.js --compilation_level=ADVANCED_OPTIMIZATIONS --jscomp_off=checkVars --externs=node --externs=all.js.externs > all.adv.min.js
#+END_SRC
(see [[https://github.com/ghcjs/ghcjs/wiki/Deployment][ghcjs deployment wiki]])*** Asterius
**** building
#+BEGIN_SRC bash#+END_SRC
**** optimizing*** WebGHC
**** building
#+BEGIN_SRC bash
wasm32-unknown-unknown-wasm-cabal new-build --project-file=webghc.project exe:$app -fjsaddle-wasm -fexamples --allow-newer
#+END_SRC**** optimizing
The wasm files could be optimized with ~binaryen~'s ~wasm-opt -Os~.
Webpackifying the javascript support could result in dramatic
savings. (TODO)*** A selection of [[http://haskell-miso.org][miso]] apps (these do not require TH)
| | ghcjs (total) | ghcjs (ccjs; dedupe; dedupe+ccjs) | Asterius | Asterius (opt) | WebGHC (total; wasm only) | WebGHC (opt) |
| todo-mvc | [[https://angerman.github.io/haskell-to-web/ghcjs/todo-mvc.jsexe/index.html][link]] (5.2M) | 3.7M; 5.7M; 3.2M | | | [[https://angerman.github.io/haskell-to-web/webghc/todo-mvc/index.html][link]] (18M; 4.6M) | |
| mario | [[https://angerman.github.io/haskell-to-web/ghcjs/mario.jsexe/index.html][link]] (4.0M) | 2.9M; 4.4M; 2.6M | | | [[https://angerman.github.io/haskell-to-web/webghc/mario/index.html][link]] (18M; 4.5M) | |
| flatris | [[https://angerman.github.io/haskell-to-web/ghcjs/flatris.jsexe/index.html][link]] (7.6M) | 5.4M; 6.9M; 4.2M | | | [[https://angerman.github.io/haskell-to-web/webghc/flatris/index.html][link]] (18M; 5.2M) | |
| snake | :( | | | | :( | |
| 2048 | [[https://angerman.github.io/haskell-to-web/ghcjs/2048.jsexe/index.html][link]] (5.4M) | 3.9M; 6.0M; 3.4M | | | [[https://angerman.github.io/haskell-to-web/webghc/2048/index.html][link]] (18M; 4.7M) | |
| simple | [[https://angerman.github.io/haskell-to-web/ghcjs/simple.jsexe/index.html][link]] (3.8M) | 2.8M; 4.3M; 2.5M | | | [[https://angerman.github.io/haskell-to-web/webghc/simple/index.html][link]] (18M; 4.4M) | |