Commit Graph

227 Commits

Author SHA1 Message Date
Théophile Choutri
a975cfc361
Add details about AddHeaders instances (#1490)
* Add details about the instances of AddHeader

Also:

* Cleanup of extensions and imports
2021-11-30 23:52:06 +01:00
Gaël Deest
3ed24fdd90
Merge pull request #1289 from acondolu/master
Better errors for partially applied combinators
2021-11-18 10:51:30 +01:00
Gaël Deest
f2bd982eaf Rename proof to g{Client,Server,Link}Proof 2021-11-18 10:25:36 +01:00
Gaël Deest
575aa70eca Cleanup 2021-11-18 10:11:45 +01:00
Gaël Deest
fca59556dd Code reorganization
Move `HasServer (NamedRoutes routes)` instance

The instance has been moved to `Servant.Server.Internal`, as the
instances for other combinators. It is necessary so that the instance
can be re-exported from `Servant.Server` without circular imports.

Otherwise, users have to import `Servant.Server.Generic` manually ;
forgetting to do so will produce confusing error messages about the
missing instance.

Move `HasClient (NamedRoutes routes)` instance

Moved so that the instance is made available when importing
`Servant.Client`, avoiding possibly confusing errors when
`Servant.Client.Generic` isn't imported.
2021-11-18 10:09:58 +01:00
Gaël Deest
b033871dfc Implement HasLink instance for NamedRoutes 2021-11-18 10:09:58 +01:00
Gaël Deest
65e3070cac Add NamedRoutes combinator
Allows users to directly embed APIs defined as records of routes into
vanilla Servant API types.

E.g.:

```haskell
data MyRoutes mode = MyRoutes
  { version :: mode :- Get '[JSON] Int
  , …
  }

type API = "prefix" :> NamedRoutes MyRoutes :<|> …
```

APIs can thus be recursively defined directly with Generic record types.
2021-11-18 10:09:58 +01:00
Gaël Deest
67a37dc3f6 Fix build error on GHC 8.6 2021-11-17 15:29:22 +01:00
Andrea Condoluci
42b7d0eb9b Type-level errors for HasLink for invalid combinators 2021-11-15 21:40:36 +01:00
Joseph C. Sible
fea40bd0fc Enable FlexibleContexts in Servant.API.ContentTypes
Starting with GHC 9.2, UndecidableInstances no longer implies FlexibleContexts.
Add this extension where it's needed to make compilation succeed.
2021-10-30 23:26:21 -04:00
akhesaCaro
6e5dffbb91 unsupporting GHC < 8.6.5, removing unecessary imports 2021-10-02 13:13:24 +02:00
Maxim Koltsov
61111178f0
Support GHC-9.0.1 2021-06-23 23:06:07 +02:00
Alp
0c961f6ebb
Fix #1405 (#1429)
Request bodies are not really supposed to be used in GET requests.
2021-06-21 22:54:29 -05:00
Paolo Capriotti
0f9cc7eeec
Add response header support to UVerb (#1420)
* Use type wrapped in Headers h to generate response

This avoids having to define MimeRender instances for Headers.
2021-06-10 17:10:50 +02:00
Samuel Gélineau
0cb2d603c4
use Capture Description if available (#1423)
* use Capture Description if available

* update golden/comprehensive.md

This is technically a breaking change, because if a Capture has both a
Description and a ToCapture instance, the Description now takes
precedence. Since this Description wasn't doing anything before, I am
guessing that most projects currently only use Description to describe
their endpoints and not their Captures, and thus that few people will be
affected by this breaking change.

* test the "no ToCapture instance" case

The case in which there is both a Description and a ToCapture instance
seems like a corner case. The more interesting cases are the one in
which there is a Description but no ToCapture instance, and the case in
which there is a ToCapture instance but no description.
2021-06-08 13:28:19 -05:00
fisx
448c444db6
Typo (#1416) 2021-04-23 10:37:48 +02:00
fisx
6ebb9e419e
Fix overlapping MimeRender instances (#1376) 2020-12-09 23:08:54 +01:00
Intolerable
a8f584f80b
add HasLink instance for UVerb (#1370) 2020-12-06 14:19:35 +01:00
Domen Kožar
0bda65e315
links: import toUrlPiece to make it clear where it comes from 2020-12-05 17:00:03 +01:00
Andrey Prokopenko
da0c83d318
Add URI fragment as a separate combinator (#1324) 2020-11-18 21:57:20 +03:00
Arian van Putten
339eec6a90
Fix overlapping instance for WithStatus (#1361)
We do not need the `ToJSON` instance for `WithStatus`
it would cause an overlap between:

```
ToJSON a => MimeRender JSON a
```

and

```
forall cty a.  MimeRendercty  a =>  MimeRender cty (WithStatus a)
```
and Servant just needs the `MimeRender` typeclass for it to work

* Add some more docs to the UVerb module

* cookbook/uverb: Change GHC versions

CI was complaining some version did not exist. Trying to bump
Also added 8.10.1

* doc/cookbook/uverb: Remove 8.4.4 from tested versions

CI was running into a cabal bug for some reason
2020-11-18 17:33:03 +01:00
fisx
c1105899f4
union verbs (#1314) 2020-10-31 20:45:46 +01:00
Maxim Koltsov
57f0b0b390
Make error messages from combinators configurable
Currently there is no way for Servant users to customize formatting of
error messages that arise when combinators can't parse URL or request
body, apart from reimplementing those combinators for themselves or
using middlewares.

This commit adds a possibility to specify custom error formatters
through Context.

Fixes #685
2020-07-17 17:10:31 +03:00
Nathan van Doorn
ff9da1cde4 Use GHC.TypeLits rather than TypeNats 2020-06-13 15:50:12 +01:00
Nathan van Doorn
6889d053c7 Add FlexibleInstances for earlier GHCs 2020-06-13 15:38:36 +01:00
Nathan van Doorn
a8184a2ee0 Add KnownStatus typeclass 2020-06-13 15:10:07 +01:00
Jan Hrcek
b9d8fbcdc1
Fix typos and grammar (#1304)
* Fix typos and grammar

* Remove redundant words, fix articles

* More language fixes

* More typo fixes and resolve TODO about missing links
2020-06-06 00:43:51 -04:00
Oleg Grenrus
8fc47edf99 Remove deprecated modules (end of 2019 is passed) 2020-01-23 13:14:24 +02:00
Jan Hrček
da365b1e47 Various haddock fixes 2019-11-12 09:29:35 +01:00
Catherine Galkina
b440af900b Implemented NoContentVerb and server instances for it 2019-09-29 14:18:13 +03:00
Oleg Grenrus
b534a8c2cf Implement forgotten mappend 2019-04-16 13:09:23 +03:00
Oleg Grenrus
73e00a431d
Merge pull request #1159 from haskell-servant/pull-1158
Added Semigroup and Monoid instances for SourceT
2019-03-27 01:42:34 +02:00
Science!
5c86e11a21 added Semigroup and Monoid instances for SourceT 2019-03-27 01:04:14 +02:00
jschaul
6cbf0d3891
add route to comprehensive API 2019-03-20 13:03:16 +01:00
Oleg Grenrus
4fab471c29 Refactor servant-client(-core)
- Rename GenResponse to ResponseF (analogous to RequestF)
- add NFData Headers
- Make Request and Response bodies be SourceIO,
  i.e. move conversions into specific implementations
2019-02-06 12:15:20 +02:00
Domen Kožar
e7655d380a
Add NoContent instance for NFData 2018-11-27 16:41:31 +00:00
Oleg Grenrus
44aabebb04
Merge pull request #1079 from haskell-servant/issue-1011
Fix issue #1011: NewlineFraming encodes newline after each element
2018-11-12 22:01:14 +02:00
Oleg Grenrus
f1eb5f93a8 Fix issue #1011: NewlineFraming encodes newline after each element 2018-11-10 01:45:56 +02:00
Oleg Grenrus
4961cc2f3a Add Arbitrary (SourceT m a) and StepT m a instances
The generated instances are pure-ish; errorless.
2018-11-09 23:49:25 +02:00
Oleg Grenrus
3001ed7990 Add mods to StreamBody 2018-11-09 21:49:53 +02:00
Oleg Grenrus
97bd6f0a40
Merge pull request #1066 from phadej/separate-streaming-client
Separate streaming client
2018-11-09 14:50:57 +02:00
Oleg Grenrus
21af9a4051 Tweak lookupResponseHeader docs 2018-11-08 18:36:31 +02:00
Oleg Grenrus
db80f41dee
Merge pull request #1064 from DanBurton/lookup-response-header
Add lookupResponseHeader
2018-11-08 18:36:09 +02:00
Oleg Grenrus
8feda81fcd Separate Servant.Client.Streaming
- as a bonus only `servant-client` depends on `kan-extensions`
2018-11-08 17:58:21 +02:00
Oleg Grenrus
7bed805cf7 Golden test for comprehensive API docs 2018-11-08 16:32:10 +02:00
Oleg Grenrus
7634e08352 Make ComprehensiveAPI part of public API
We cannot simply tweak it, it will break tests of other packages.
Including packages not in this repository.
2018-11-06 13:35:47 +02:00
Oleg Grenrus
45c1cbdfd5 Refactor Stream stuff
- Introduce SourceT, which is simple variant of "correct `ListT`".
  There are another variants possible (like in `streaming`),
  but I'm not sure there's much real difference.

- Introduce `Codensity`. There's a flag if people don't want to depend
  on `kan-extensions`.

- `StreamGenerator` and `ResultStream` are both `SourceT`.
  `Stream` combinator in `servant-client` uses `Codensity` for CPS.

- Add servant-machines, servant-conduit, servant-pipes
- Add streaming cookbook: just code, no explanations.
- Add a script to run streaming 'benchmarks'
2018-11-05 15:48:47 +02:00
Dan Burton
e604b930dc
Add lookupResponseHeader 2018-10-28 01:36:40 -04:00
Domen Kožar
c7f616ea2d
ResponseHeaders: export GetHeaders' 2018-10-14 12:15:41 +01:00
Nathan van Doorn
7133e9dad2 Add bifunctors instances for Servant.API.Alt
These mirror the corresponding instances for (,)
2018-09-05 13:15:42 +01:00