No description
Find a file
Gaël Deest 49c7dd2e8d Implement HasServer (NamedRoutes routes)
We define `ServerT (NamedRoutes api) m` as `api (AsServerT m)`, so that
the server of an record-defined API is a record of handlers.

The implementation piggy backs on the instance for “vanilla” servant
types with `(:<|>)`, using the `GServantProduct` for converting backd
and forth between the record / vanilla servers.

The main difficulty is that GHC needs to know that this operation is
legit, which can be expressed as the fact that:

```
GToServant (Rep (ServerT (NamedRoutes api))) m ~
ServerT (GToServant (Rep (api AsApi))) m
```

plus a few additional constraints.

This is easy enough for `route`, as we know that `m ~ Handler`. But in
the case of `hoistServerWithContext`, the two involved monads are
unknown ; in other words, this constraint needs to hold `forall m.`

Switching `-XQuantifiedConstraints` on is not sufficient, as our
constraints involve type families (`Rep` and `ServerT`). Our trick is to
use an intermediary typeclass, `GServer`, as a provider of evidence (in
the form of a `Dict`) that our constraints are indeed satisfied for a
particular monad.

The only instance of `GServer` is defined along with it, so it is
practically invisible to users.
2021-10-02 16:44:44 +02:00
.github unsupporting GHC < 8.6.5 in the CI 2021-10-02 13:10:20 +02:00
changelog.d Servant docs curl (#1401) 2021-08-19 13:11:00 +02:00
doc remove tested-with (GHC < 8.6.5) from cabal 2021-10-02 13:13:33 +02:00
nix add missing dependencies into shell.nix 2021-10-02 13:10:20 +02:00
servant Add NamedRoutes combinator 2021-10-02 16:27:00 +02:00
servant-client remove tested-with (GHC < 8.6.5) from cabal 2021-10-02 13:13:33 +02:00
servant-client-core remove tested-with (GHC < 8.6.5) from cabal 2021-10-02 13:13:33 +02:00
servant-client-ghcjs Allow bytestring-0.11 (#1386) 2020-12-16 11:04:49 +01:00
servant-conduit remove tested-with (GHC < 8.6.5) from cabal 2021-10-02 13:13:33 +02:00
servant-docs remove tested-with (GHC < 8.6.5) from cabal 2021-10-02 13:13:33 +02:00
servant-foreign remove tested-with (GHC < 8.6.5) from cabal 2021-10-02 13:13:33 +02:00
servant-http-streams remove tested-with (GHC < 8.6.5) from cabal 2021-10-02 13:13:33 +02:00
servant-machines remove tested-with (GHC < 8.6.5) from cabal 2021-10-02 13:13:33 +02:00
servant-pipes remove tested-with (GHC < 8.6.5) from cabal 2021-10-02 13:13:33 +02:00
servant-server Implement HasServer (NamedRoutes routes) 2021-10-02 16:44:44 +02:00
.gitignore Servant docs curl (#1401) 2021-08-19 13:11:00 +02:00
.stylish-haskell.yaml Reformat servant 2018-03-11 17:58:31 +02:00
cabal.ghcjs.project A new version of hashable isn't compitable with our ghcjs. A max bound version is needed in the Cabal file 2021-10-02 13:32:15 +02:00
cabal.project Support GHC-9.0.1 2021-06-23 23:06:07 +02:00
CONTRIBUTING.md Fix typos and grammar (#1304) 2020-06-06 00:43:51 -04:00
default.nix Build servant repo with nix. (#1288) 2020-06-06 00:04:32 -04:00
hlint.yaml Update hlint.yaml and fix some hints in servant and servant-server 2018-01-26 17:38:57 +02:00
README.md Update IRC link in readme to point at libera 2021-05-26 09:05:50 +01:00
servant.png Update READMEs 2015-04-20 15:48:37 +02:00
setup.py Add simple setup.py for RTD 2018-07-06 12:02:00 +03:00
sources.txt Support http-client’s CookieJar in servant-client 2018-01-26 18:45:52 +02:00
stack-ghcjs.yaml Add stack file for testing GHCJS. 2018-03-19 16:26:57 +01:00
stack.yaml Add serveWithContextT, ServerContext (#1441) 2021-08-21 19:15:02 +02:00
stack.yaml.lock Add serveWithContextT, ServerContext (#1441) 2021-08-21 19:15:02 +02:00
streaming-benchmark.sh Refactor Stream stuff 2018-11-05 15:48:47 +02:00

servant - A Type-Level Web DSL

servant

Getting Started

We have a tutorial that introduces the core features of servant. After this article, you should be able to write your first servant webservices, learning the rest from the haddocks' examples.

The core documentation can be found here. Other blog posts, videos and slides can be found on the website.

If you need help, drop by the IRC channel (#haskell-servant on libera.chat) or mailing list.

Contributing

See CONTRIBUTING.md

Release process outline (by phadej)

  • Update changelog and bump versions in master
    • git log --oneline v0.12.. | grep 'Merge pull request' is a good starting point (use correct previous release tag)
  • Create a release branch, e.g. release-0.13
    • Release branch is useful for backporting fixes from master
  • Smoke test in servant-universe
    • git submodule foreach git checkout master and git submodule foreach git pull to get newest of everything.
    • cabal new-build --enable-tests all to verify that everything builds, and cabal new-test all to run tests
      • It's a good idea to separate these steps, as tests often pass, if they compile :)
    • See cabal.project to selectively allow-newer
    • If some packages are broken, on your discretisation there are two options:
      • Fix them and make PRs: it's a good idea to test against older servant version too.
      • Temporarily comment out broken package
    • If you make a commit for servant-universe, you can use it as submodule in private projects to test even more
  • When ripples are cleared out:
    • git tag -s the release
    • git push --tags
    • cabal sdist and cabal upload

TechEmpower framework benchmarks

We develop and maintain the servant TFB entry in https://github.com/haskell-servant/FrameworkBenchmarks/

To verify (i.e. compile and test that it works)

./tfb --mode verify --test servant servant-beam servant-psql-simple --type json plaintext db fortune

To compare with warp

./tfb --mode benchmark --test warp servant servant-beam servant-psql-simple --type json plaintext db fortune

To compare with reitit (Clojure framework)

./tfb --mode benchmark --test reitit reitit-async reitit-jdbc servant servant-beam servant-psql-simple --type json plaintext db fortune

You can see the visualised results at https://www.techempower.com/benchmarks/#section=test

Nix

A developer shell.nix file is provided in the nix directory

See nix/README.md