Cloudflare Workers

Has anyone looked into writing Cloudflare workers in OCaml?

They recently announced support for more language, including ReasonML:

It would be great if there was an option to use OCaml and js_of_ocaml instead. I’d be happy to look into this when I have time but wanted to make sure nobody else had already started the work.

1 Like

This is largely based on a cusory look at the pages you mention so take it with a grain of salt.

It seems “the language support” mentioned on that page comes under the form of project templates. Unless I’m mistaken, once you have sifted through the “modern” amount of metadata these templates have, all what remains to be provided is a JavaScript file.

And that’s what the beloved js_of_ocaml compiler compiles to.

So simply start with the JavaScript template and replace the index.js file there by your js_of_ocaml generated one.

1 Like

ReasonML is OCaml, btw. The Reason template uses the BuckleScript compiler, which can compile standard OCaml to JavaScript just fine.

Thanks, maybe I should have been clearer. I was wondering whether anyone had already started on a template that uses the OCaml toolchain, ie opam, dune, js_of_ocaml instead of npm and bucklescript.

1 Like