servant is at its core a type-safe and very extensible library for defining REST-y webservices around some core "database operations", in just a few very simple lines, e.g:
mkResource "users" pgsqlcontext pgexceptions & addWith Users.add & listAllWith Users.view & deleteWith Users.delete
which can then be turned into a scotty webservice by calling
runResource (from servant-scotty -- the only backend we have for now) on it.
- Getting started with servant
- Haddocks of individual packages:
servant a couple of times because there's no point
in tying it to a particular web framework or database backend (and it was tied to scotty, in previous rewrites). I've
kept the type tricks but worked hard enough to completely separate
the resource description bits from the parts that actually are about
setting up a webservice just from a description or turning results into proper json responses and what not.
In addition to the standard REST operations provided through the various
Prelude modules in the servant packages, you can define your own in a simple
and type-safe way.
Also, right now, I'm focusing on our use cases at Zalora, where we need pooling support on top of /PostgreSQL/ connections, and tend to write web apps using scotty. Nothing keeps you from writing a "backend" for your favorite web framework, it would most likely be quite similar to the scotty one, so you can just look at its code. However, if I don't have a write up yet about how that should be done by the time you want to do that, I gladly encourage you to shoot me an email. The documentation links above should however help a lot.