Servant
Servant is a Haskell library for defining type-safe web APIs and deriving corresponding server and client implementations.
Learn Haskell by Example
Servant is a Haskell library ecosystem for defining type-safe web APIs and generating server and client implementations from API descriptions.
- How it is used
- Defines a todo-list HTTP/JSON API, implements its server, and derives a CLI-facing client from one API description.
- How deep it goes
- Works through API operators, concrete handlers, HTTP errors, middleware, and generated clients, while deferring the internals of DataKinds and TypeOperators.
- Examples
- Builds a todo API with entries, add, and toggle endpoints, database-backed handlers, a root HTML route, and derived client actions.
- What you can do after
- Apply it via Servant to specify a typed HTTP API, assemble matching handlers, add middleware, and derive client functions.
Functional Design and Architecture: Examples in Haskell
servant-client is a Haskell library that derives client functions for making HTTP requests from Servant API specifications.
- How it is used
- Deploys typed HTTP clients and RESTful servers while keeping business logic independent of the communication channel.
- How deep it goes
- Explains type-level API schemas, generated client actions, and framework integration, but leaves uncommon requirements such as streaming difficult.
- Examples
- Uses meteor and asteroid POST endpoints, JSON payload types, generated ClientM functions, and reporting-error conversion.
- What you can do after
- Build it from scratch: define a shared API type and derive client operations for framework-managed HTTP requests.
Read how Functional Design and Architecture: Examples in Haskell explains Servant →
Related concepts
- contractproduces · An API contract is a specification of the operations, data, and behavioral expectations that govern interactions between software components.
- Applicationproduces · In WAI, an Application is a low-level HTTP interface that receives a request and produces a response.
- embedded domain-specific languagekind of · An embedded domain-specific language is a language tailored to a particular problem domain and expressed within a host programming language.
- type-safe APIimplements · A type-safe API is an application programming interface whose operations, inputs, and outputs are specified and checked to prevent invalid type combinations.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

