Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Dario Teixeira <dario.teixeira@nleyten.com>
To: Rudi Grinberg <rudi.grinberg@gmail.com>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Functorising over Cohttp's backends
Date: Mon, 29 Aug 2016 19:42:10 +0100	[thread overview]
Message-ID: <c99c0fc01ea0bc77cc88eca25701847b@nleyten.com> (raw)
In-Reply-To: <20160829153945.424bhlwpk7pmm6em@rgcaml.localdomain>

Hi,

And thanks for the comprehensive response, Rudi!


> The Cohttp API at its present state doesn't really offer a good
> abstraction for creating backend independent HTTP clients and
> servers.
> 
> Luckily, the request and response types are backend independent. And
> so is the http body type if you aren't streaming. This means that
> you can fairly easily create a light application specific abstraction
> for yourself.

Yes, I'm leaning towards just functorising over "IO" and nothing
else.  I thought about functorising also over "Body", but I reckon
the API will be much simpler if I dictate that the body must be of
type Cohttp.S.Body.t, and place on the user the burden of converting
to/from this type if the backend body implementation extends over
Cohttp.S.Body (as is the case with Cohttp_lwt_body).

I reckon a truly universal solution would also need to functorise
over "Request" and "Response", but a) that way lies madness, and b)
as you pointed out, luckily these are presently backend-independent.


> To summarize, it's unfortunate that Cohttp doesn't provide a real
> server (or client) abstraction. But it's kind of hard to do without
> making a wrapper that tries to abstract away the differences between
> different backends. Hiding away the details of Async and Lwt was
> always an anti-goal for Cohttp anyway.

Cohttp is perhaps the poster child for how the Lwt/Async schism
makes many APIs way more complex than they should be!  (Not that
there's an easy solution to this situation...)

Best regards,
Dario Teixeira


  reply	other threads:[~2016-08-29 18:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-29 13:53 Dario Teixeira
2016-08-29 15:39 ` Rudi Grinberg
2016-08-29 18:42   ` Dario Teixeira [this message]
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=c99c0fc01ea0bc77cc88eca25701847b@nleyten.com \
    --to=dario.teixeira@nleyten.com \
    --cc=caml-list@inria.fr \
    --cc=rudi.grinberg@gmail.com \
    /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