Servant provides a typed, declarative way to describe HTTP APIs in Haskell. It fits an architecture where command-line business logic remains channel-agnostic while HTTP clients and servers are added through dependency injection. section 14.1 section 14.1.1
A single API type describes routes, request payloads, content formats, HTTP methods, and response types. The same schema can drive both a typed HTTP server and a compatible client. section 14.1.1
A practical Servant integration separates responsibilities:
- Declare endpoints with type-level combinators such as routes, request bodies, JSON formats, and POST responses. section 14.1.1
- Derive client functions from the API type; supplied payloads produce ClientM actions that represent HTTP calls. section 14.1.3
- Hide library access behind application interfaces and interpret those operations within the surrounding framework. section 14.1.3
AstroAPI client
An AstroAPI can expose meteor and asteroid POST routes. Applying Servant's client derivation yields meteor :: MeteorTemplate -> ClientM MeteorId and asteroid :: AsteroidTemplate -> ClientM AsteroidId; application code then executes these actions through a framework operation and maps ClientError into a domain error. section 14.1.1 section 14.1.3
Figure 14.1 The Servant web server and the HTTP model
Use the architecture diagram to see how the shared HTTP model connects the Servant client, server, and application framework. section 14.1

