As the title suggests, I’m looking for repos that showcase GHC’s WASM capabilities that I can clone and play with. I have looked at Glasgow Haskell Compiler / ghc-wasm-meta · GitLab which is a good start, but it’s short on end to end demos.
Particularly I am looking for things which highlight:
Running the wasm program from within a host program, either in Javascript or Rust
Compiling pure top-level functions (i.e. something other than a self contained main :: IO ()) which is used as FFI in the host program.
Anything which exhibits how Integer/Natural are dealt with in GHC 9+, and how you get around this if you’re using wasm32.
I don’t really care if it’s run in the browser or using e.g. node, either are welcome.
My actual use case (in case it matters) is that I want to be able to execute the same pure function in both Haskell and ultimately inside a rust program or in the browser. The function has type something like [Integer] -> [Integer] and only depends on base and containers (i.e. nothing eccentric).
My Brassica compiles a library to WASM. You can find details in BUILDING.md and the last paragraph of ARCHITECTURE.md, and the code under gui/brassica-interop-wasm and gui/brassica-web.
I have made a couple of simple demo Web apps that are deployed to GitHub pages. They are meant to be starting points of making games using Yampa library (though the first of the following examples does not really need Yampa). The game step function is called from JavaScript, which performs the logical step which in turn calls wrapped JS Canvas functions to perform drawing via FFI.