Solid apps in OCaml
Hi r/solidjs!
At Hypha we build software in OCaml, with an open stack of our own. The backend part is covered by Spindle, our fantastic web framework, so nothing to complain about there. The frontend is a different beast, though.
What would be really great is to build full-stack reactive apps in OCaml on Solid, from one coherent set of libraries, for ourselves and for our customers, so that backend and frontend share one great language, one toolset, and the same high bar.
Unfortunately for us, Solid never had complete OCaml bindings, so after some investigation I made our own, for Solid itself and for Kobalte. And for the sake of having one of the best UI kits around, I also ported HeroUI, nearly in full, from React and React Aria onto Solid and Kobalte. Then came charts (rhp) and Gravity UI's icons. Sorted.
Even if you've never tried OCaml, you should be able to read the code, as it's pretty close to JSX/TSX markup:
module S = Solidtype.Solid
module Jsx = Solidtype.Jsx
let%component make ~(label : string) () =
let count, set_count = S.create_signal 0 in
<button on_click=(fun _ -> S.update set_count (fun c -> c + 1))>
(fun () -> Jsx.string (label ())) ": " (fun () -> Jsx.int (S.get count))
</button>Why OCaml? Glad you asked. Agents now write much of our code, and a model guesses wherever nothing tells it otherwise. OCaml's types leave it much less room to guess, and the compiler is fast enough to answer inside an agent's loop. It's also nice to have one language for the whole stack, as TypeScript or Clojure gives you, and OCaml does too.
The docs have plenty of live examples and everything you or your agents need to build modern web apps in OCaml and Solid.
