GHC’s WASM backend is already really useful! I also used it to port one of my own programs to the browser [0], albeit not using the DOM as this person did. Documentation is still sparse, but it’s a very similar process to creating a shared foreign library. (At the very least, I tried to document what I could.)
Looks cool, I'm not much into webassembly... but I see just fews lines of Haskell code produced a gzipped wasm of 448K. How does this compares to other languages?
It think you might not need to go via CString to get to the browser, given that the browser side doesn't care about NUL termination either. I think you could use Data.ByteString.Internal to grab the ForeignPtr/length out of the BS constructor directly.
Maybe, but probably not. Postgrest still needs to talk to Postgres over the Postgres wire protocol, which isn't possible with wasm in the browser because there is no raw socket API. However, I'm sure there are some cool hacks you could do like running postgres-wasm "locally" (also within the browser) and having postgres talk to it. You'd still need to modify Postgrest to change how it speaks to Postgres, though.
This is also assuming you're running the WebAssembly in the browser. If you're running it in something like WASI, you might have access to a raw socket API and then maybe it's a different story.
Maybe: if you have a postgres (no "t") service provider and you can't install postgrest on it, then you can now possibly run it in the browser. Though, it adds the problem of how do you connect one with the other. Even if there existed a workaround to make this connection, it might just not be worth it.
[0] https://github.com/bradrn/brassica