Skip to Content
Learn Haskell by Example
book

Learn Haskell by Example

by Philipp Hagenlocher
December 2024
Beginner content levelBeginner
456 pages
13h 37m
English
Manning Publications
Content preview from Learn Haskell by Example

17 APIs using Servant

This chapter covers

  • Providing typesafe APIs, using Servant
  • Implementing a WAI application
  • Automatically deriving clients for the API

In the last chapter, we discussed how to implement the conversion of Haskell data to and from JSON and how to store that data in a database. We also provided a few types for the todo list API we want to use.

In this chapter, we will complete the project by first exploring the Servant ecosystem of libraries and packages to define a typesafe API and define a server for it. After doing so, we extend the server to also serve HTML to the client. We then wrap things up by automatically deriving a client application for the API server.

17.1 Defining a typesafe API

For our server, we ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Get Programming with Haskell

Get Programming with Haskell

Will Kurt
Haskell in Depth

Haskell in Depth

Vitaly Bragilevsky

Publisher Resources

ISBN: 9781633438934Supplemental ContentPublisher SupportOtherPublisher WebsiteSupplemental ContentErrata PagePurchase Link