also: the current ghc-in-browser playground itself is just a ghc api program that interprets a Main.hs program with main :: IO (); to get a full ghci-like repl experience in the browser with support for all ghci commands is another chunk of work not covered by !15000 yet.
Very cool! It’s so far along now.
I’ve started working on a web-based game through PixiJS, using a WASM compiled Haskell library for the game logic. We’ll see how it goes! Having it all in WASM will make distribution a lot simpler.
I didn’t know GHC needed to call the C compiler for anything other than the FFI. Is there really no way around that?
I’m guessing for the CPP?
You can already (try to) use CPP. It will give this error:
panic! (the 'impossible' happened)
GHC version 9.14.0.20251031:
/tmp/Main.hs:1:1: error:
createPipe: unsupported operation (Operation is not supported)
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
i could also make clang etc run in the browser at well, and patch process to introduce my own hacked way to spawn subprocesses: shared memory and pipes won’t work but basic waitpid could work. it’s not impossible, it’s just too hacky that i’d really prefer not going that route.
so in the absense of c compilers in the browser, CPP won’t work. and JSFFI imports (foreign import javascript) doesn’t work unless already precompiled to one of the shared libraries to be loaded, though this one is easier to fix and i might fix it some time from now. if you see other language features not working due to similar reasons, you’re welcome to report.
Lack of support for type-checker plugins is blocking use of WASM in an application I have in mind. See Compiler plugins not supported in the Wasm backend (#25935) · Issues · Glasgow Haskell Compiler / GHC · GitLab . So that would be the #1 item on my wishlist.
To test it out, I whipped up a short demo that shows how you can interface with libraries like pixi.js to start rendering in the browser from Haskell via WASM. Excellent work @TerrorJack, looking forward to more!
Update: Now runs on a Steam Deck
The compiler crashes with this source code ![]()
import Data.Function (fix)
main = putStrLn $ fix error