Witx (WebAssembly interface description) to Haskell?

I’m browsing around what it would take to compile Haskell to WebAssembly so that it can run on Fastly’s edge compute platform. One issue is that one needs to have bindings to the low-level Fastly interface, i.e. it’s ABI. They provide rust bindings (in addition to a convenient higher level idiomatic library), and that would have to be replicated on Haskell.

Unfortunately it’s not really fully documented, at least I did not find something. But I did at least find a machine-readable specification of the interface:

This is in a format called “witx”. So I’m wondering if someone has already build a tool that takes such a description and turns it into a Haskell module? (I assume the answer is no, but still posting that others interested can find this post)

5 Likes

I guess I should ping @acfoltzer who seems to have contributed to the mentioned repository :slight_smile:

2 Likes

I made some process manually binding parts of the Fastly ABI, see Haskell via WebAssembly on Fastly.

3 Likes

Howdy @nomeata! witx is sorta-deprecated at this point. We’re going to be transitioning over to wit as we adopt the Wasm component model, but in the meantime it’s still the canonical definition for the Fastly ABI. At this point, I would recommend supporting wit for your codegen needs. Our JS SDK is starting to use it for Wasm-side codegen on an experimental basis, you can find that file here, though note that it’s not canonical.

Really looking forward to what you’re working on here. Please let me know if you have any questions or feature requests :sparkles:

4 Likes

Thanks for the insight! I don’t have much concrete plans; the proof of concept is done. So I probably won’t do anything right now, maybe more when I have a something new that I need to host somewhere and then want to try it on fastly. And then I guess the next step would be to generate Haskell bindings based on https://github.com/fastly/js-compute-runtime/blob/main/c-dependencies/js-compute-runtime/xqd.wit. But if someone beats me to me, even better :smiley:

2 Likes

Note that file also just moved as part of a standardizing of name conventions in that repo; here’s a permalink: js-compute-runtime/c-at-e.wit at ce4be9c9565e971f7bb67ff081f9de5f2d932a95 · fastly/js-compute-runtime · GitHub

1 Like