Spindle is a web framework for OCaml 5, designed around Eio’s effect-based concurrency and multicore execution. Its pitch is to combine ergonomic application code with strict protocol behavior: it includes its own HTTP/1.1 engine and says its compliance with HTTP, WebSocket, form-data, and Structured Fields standards is backed by tests. The framework also emphasizes end-to-end typing. OCaml types can generate JSON encoders and decoders, validate incoming data against constraints, and produce schemas for frontend use with Zod or Melange.
The README’s bill-splitting example shows the intended workflow: define constrained request and response types, implement a handler, and declare a typed route. Spindle can then generate interactive OpenAPI documentation from the routes, including schemas, field bounds, and possible errors. The framework also bundles SQLite and PostgreSQL integrations, WebSockets, server-sent events, sessions, logging, tracing, and metrics. It is installed through the project’s opam repository and depends on OCaml 5.5 or later; the code is MIT-licensed. The repository presents Spindle as a comprehensive option for building typed APIs in modern OCaml, rather than a minimal routing library.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.