ghc itself can now run purely client-side in the browser, here’s a haskell playground demo. terms and conditions apply, and i’ll write up more detailed explanation some time later, but i thought this is a cool thing to show off how far the ghc wasm backend has advanced ![]()
This is very cool! I wonder how easy it would be to load some packages; cabal in the browser when? I’m also wondering how usable Agda in the browser would be.
I think I found a bug: ghc options persist even after I change them.
Also -with-rtsopts=-s does not work, sadly. Edit: Ah, that’s because it is interpreted.
This is awesome!
Perfect for building a fully interactive Haskell online course! ![]()
Awesome work!
Browser reports:
- In Brave, after a few seconds unresponsive, it loads. It shows: “Could not create web worker(s). Falling back to loading web worker code in main thread, which might cause UI freezes. Please see GitHub - microsoft/monaco-editor: A browser based code editor
You must define a function MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorker”. The Run button works. - In Safari, the same message, but the Run button remains disabled.
Excellent work - the efforts to bring Haskell to WASM are a huge boon to our ecosystem and userbase!
Can’t run it on my tablet (wasm), curious: is this running the type checker or also code gen to wasm?
It runs the code, but it seems like it uses the bytecode interpreter.
What modifications were to GHC for it to be compiled to WASM?
cabal won’t work in the browser due to lack of process support; but it’s possible to use wasm32-wasi-cabal to precompile some third party packages to wasm and make this playground support them as well.
you might be interested to check GitHub - agda-web/agda-wasm-dist: Distributions of Agda executable compiled into WebAssembly.; afaik they even compiled GitHub - agda/agda-language-server: Language Server for Agda to wasm, not sure how usable it is currently
thanks for the report! i pushed an update which should have fixed it.
that’s right; ghc in browser can’t invoke the c compiler and it can only interpret haskell modules via bytecode.
thanks for the reports! a few seconds of freeze during start-time is expected, since it needs to download ~50M of a rootfs tarball and extract it, then link the ghc library and all its dependencies. as for safari, it’s strange since i i just landed a workaround for a webkit bug that breaks the wasm dynamic linker a few days ago, i’ll take a closer look later.
the ghc library already mostly works when compiled to wasm, and it can parse/typecheck/desugar stuff. the bottleneck is the linker/loader part, for it to be useful it needs to be able to dynamically load and execute haskell code. i landed a couple of ghc patches recently to push towards that direction, and the last one that gets us towards the haskell playground (not landed yet) is Draft: Support running GHC fully client-side in the browser (!15000) · Merge requests · Glasgow Haskell Compiler / GHC · GitLab
Which packages are installed by default?
now chrome will consume even more memory ![]()
Awesome work!