hn.today

Show HN: Spindle – a full-featured, type-safe web framework for OCaml 5

github.com3 points0 comments
Screenshot of Show HN: Spindle – a full-featured, type-safe web framework for OCaml 5

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.

Read on github.com0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.