RFC: Delegate Verb/NoContentVerb implementations to MultiVerb. #1860
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
NOTE: This PR is based on #1859 . You may skip the first two commits when reviewing (but the second one is necessary for the tests to pass).
The goal of this PR is to start exploring the standardization of the core of servant around One True Endpoint Combinator (hereinfafter referred to as OTEC) that supports all of our use cases.
Current situation is more or less the following:
Verb/NoContentVerbis the historical endpoint combinator inservant.The
Streamcombinator is distinct fromVerband supports advanced streaming usages with custom framing and arbitrary item type.UVerbimproved uponVerbby allowing multiple instances, but leaks details of the HTTP protocol into handler types (namely HTTP status codes) and is about to be deprecated (see Deprecate UVerb #1820 ).MultiVerbis the closest thing we have to OTEC but:RespondStreamingis limited toSourceIO ByteStringand is not as expressive as the currentStreamcombinator.Verbthat need to be clarified.This PR tries to re-express the
Verbsemantics forHasServerandHasClientin terms ofMultiVerbinstances, in order to explore the feasibility of the OTEC vision, verify that MultiVerb provides everything we need, and work out some backward compatibility solution. It turns out to be easier than I feared, but does require some breaking changes. Notably:KnownStatusinstances, not justKnownNat.Verbmethod parameter was (probably) needlessly polykinded ; it must now be restricted toStdMethod, as this is whatMultiVerbdoes, in order to support delegation.MultiVerbandVerb:a)
MultiVerbincorrectly removed duplicate headers when parsing responses (see Fix handling of duplicate headers in MultiVerb client #1859 ), which madeVerbtest case failed when expressed in terms of MultiVerb. We fix this.b)
Verbclient implementation did not really check that headers were provided even when marked as mandatory. We could break user code that relies on some server not honoring the Servant API from which the client was derived.Hopefully we can do something with the work on this branch.
Doing the same thing for
Streamis essentially feasible but requires extendingRespondStreamingto support the features required byStream(or add a new response type toMultiVerb). I have some non-primetime-ready code around that I'll consolidate in a PR later.The end goal would be:
MultiVerbasVerb, and possibly move currentVerbto a dedicated module, or rename it toSimpleVerb.