Wasm via Golang backend


Copy/pasted from the purescript-native wiki:


There’s not much to it. Instead of building a regular executable with

$ spago build -- -g corefn && psgo

you add a couple of Go environment variables:

$ spago build -- -g corefn && GOOS=js GOARCH=wasm GOFLAGS=-o=main.wasm psgo

You can then test it using the instructions from the relevant section of the Go wiki.

I have only tested in the browser (both Safari and Chrome on macOS) using their instructions. Specifically, I tried TCO.purs and it ran fine. If you test in the browser, make sure to enable your browser’s javascript console to see the output.

See the Go wiki section on WebAssembly for more information.

10 Likes