From: Dario Teixeira <dario.teixeira@nleyten.com>
To: caml-list <caml-list@inria.fr>
Subject: [Caml-list] Functorising over Cohttp's backends
Date: Mon, 29 Aug 2016 14:53:28 +0100 [thread overview]
Message-ID: <f80651ae31d96eac1115bf124d97eac4@nleyten.com> (raw)
Hi,
Suppose I have a function "make_callback" which creates a callback
ready to be given to Cohttp's Server.make. Here's its signature:
type callback =
Cohttp_lwt_unix.Server.IO.conn * Cohttp.Connection.t ->
Cohttp.Request.t ->
Cohttp_lwt_body.t ->
(Cohttp.Response.t * Cohttp_lwt_body.t) Cohttp_lwt_unix.Server.IO.t
val make_callback: unit -> callback
Note that it's tied to the Lwt+Unix instantiation of Cohttp. Now,
I wish to make it more generic, so it can be used with the Async
backend, for instance.
There's more to it than just using a functor for abstracting over the
IO monad, unfortunately. In particular, the connection type and the
body are also backend-dependent. Anyway, Cohttp's API is notoriously
hard to navigate. Is the generic signature I'm looking for already
defined somewhere, or are the backends so distinct that I might
as well forget about functorising the interface and thus force the
Lwt+Unix backend on my API? (It's the only backend I use myself...)
Thanks in advance!
Best regards,
Dario Teixeira
next reply other threads:[~2016-08-29 13:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-29 13:53 Dario Teixeira [this message]
2016-08-29 15:39 ` Rudi Grinberg
2016-08-29 18:42 ` Dario Teixeira
2016-08-29 21:51 ` Daniel Bünzli
2016-08-30 9:08 ` Malcolm Matalka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f80651ae31d96eac1115bf124d97eac4@nleyten.com \
--to=dario.teixeira@nleyten.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox