fetch
example: use servant-client-js
, remove Miso.Fetch
#904
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.
This PR removes the Servant functionality from
Miso.Fetch
, instead recommending users to useservant-client-core
with a backend of their choice, while recommendingservant-client-js
.Currently, we need to use a patched
servant-client-js
, see Update for newer servant-client-core, support GHC JS backend morganthomas/servant-client-js#6.Depending on upstream responsiveness, we might want to fork it, or even vendor it within Miso; it is very lightweight.
We keep the
fetchJSON
function for simple use cases.New section in the README on how to interact with HTTP APIs.
The commits can be reviewed individually.
Background on
servant-client-core
The general idea of
servant-client-core
is as follows:It provides the
HasClient
class, defined for all servant combinators1.The
Fetch
class fromMiso.Fetch
is basically a less general reimplementation of this.Any Servant API satisfying
HasClient
can be run using a backend implementing theRunClient
/RunStreamingClient
class.There are various existing frontend/browser implementations of this, of varying quality:
servant-client-ghcjs
, only works for GHCJS, based on XHRservant-jsaddle
, based on JSaddle, using XHRghcjs-dom
which is a huge dependency.servant-client-js
, based on JSaddle, usingfetch
servant-client-fetch
, using the Wasm JSFFI, usingfetch
For
Miso.Fetch
, @georgefst essentially implemented/is implementing (Further generalise the fetch API #888) another backend, based on JSaddle andfetch
(as well as starting with Wasm-specific optimizations in Further generalise the fetch API #888).Footnotes
Third-party adaptors usually also provide instances in a separate
-client
package, see e.g. servant-auth-client. ↩