haskell-servant / servant

Main repository for the servant libraries — DSL for describing, serving, querying, mocking, documenting web applications and more!
https://docs.servant.dev/
1.8k stars 407 forks source link

Split up HasServer, HasClient #1731

Open fisx opened 3 months ago

fisx commented 3 months ago

For unit-testing, we need HasClient instance that gives us clientWithRoute, but the instance does not require a RunClient instance.

The easy solution is to write a RunClient instance using undefined, but it would be nicer to keep separate things separate:

type HasClient m api = (RunClient m, HasClient' m api)
class HasClient' m api where ...

... and then require RunClient where necessary in order to implement the HasClient' instance, instead of in the class.

Any concerns or objections? If not I may make a PR.

(ping @pcapriotti)

fisx commented 3 months ago

the down side i guess is that the constraints will say HasClient, and the instances will be of HasClient'. not entirely pretty.

fisx commented 3 months ago

or we could drop HasClient and always add an explicit RunClient where needed, also where the instance is used?