Haskell via WebAssembly on Fastly

If you go to https://haskell-on-fastly.edgecompute.app/ you see a very boring page that is produce by Haskell code compiled to WebAssembly and running on Fastly’s Compute@Edge infrastructure.

The code behind it is on

It’s a demo only so far, not a complete and production-ready support (and I don’t know if I’ll build that).

Thanks a lot to @TerrorJack for building these things, and helping me.

19 Likes
  • Haskell’s GHC compiler supports compiling to WebAssembly since GHC-9.8

Did you mean 9.6? Or is this using something that won’t be “stable” until 9.8?

1 Like

The latter, the WebAssembly backend is going to ship with 9.8. If you go to https://haskell-on-fastly.edgecompute.app/ it more correctly says:

Compiled by ghc 9.7.20230215 running on wasi-wasm32

3 Likes

So IIUC, Fastly’s server is running a wasm binary which fetches GET/POST params and spits out html?
And you use the Fastly.hs interface to do the IO?

(So this is not about running Haskell in the browser, but on the server, for servers that don’t let you run regular Haskell binaries, but require .wasm binaries.)

3 Likes

Exactly!

(And “Exactly!” has less than 20 characters)

3 Likes