I built the RealWorld app in Lean 4

Abstract. I built RealWorld, the reference full-stack app with official test suites, entirely in Lean 4. Can it be done? Yes. Is it ready for production? Somewhat. Can it be made correct by construction? Partly. It can certainly be made more robust than the average full-stack app, though.

Figure 1. The home page, rendered on the server by Lean.

1Introduction

Lean 4 is a functional programming language in the same family as Haskell and OCaml. Most people know it as a proof assistant. Lately its standard library has also gained an HTTP server. The community is writing the other libraries that ordinary apps need too, like Postgres drivers, cryptography and HTML rendering.