From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 794B07FE47 for ; Mon, 7 Mar 2016 10:09:02 +0100 (CET) IronPort-PHdr: 9a23:B58GmxJRAp4Yqlr5JtmcpTZWNBhigK39O0sv0rFitYgVKvnxwZ3uMQTl6Ol3ixeRBMOAu60C27Kd6vmxEUU7or+/81k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i760zceF13FOBZvIaytQ8iJ35vxh7j5osSCKyxzxxODIppKZC2sqgvQssREyaBDEY0WjiXzn31TZu5NznlpL1/A1zz158O34YIxu38I46Fp34d6XK77Z6U1S6BDRHRjajhtpZ7djgTYVQaE+lcbV2wXlFIIX1mEv1nGWcLUuy/xse54kAyTIcTyTrl8DTGn5rtiTBzhoCgCPj89tmrQj5ojorhcpUeaphl4xcb/epycMvdlNvfGfNYdQyxKRNtYUSFaRNnkN9QnCrYRe+FCoN+u9BM1sRKiCFz0V6vUwThSiyqzgPQ3 Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=Neutral smtp.pra=simon.cruanes.2007@m4x.org; spf=Pass smtp.mailfrom=SRS0=gmeT=PD=m4x.org=simon.cruanes.2007@bounces.m4x.org; spf=Pass smtp.helo=postmaster@mx1.polytechnique.org Received-SPF: Neutral (mail2-smtp-roc.national.inria.fr: domain of simon.cruanes.2007@m4x.org does not assert whether or not 129.104.30.34 is permitted sender) identity=pra; client-ip=129.104.30.34; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="SRS0=gmeT=PD=m4x.org=simon.cruanes.2007@bounces.m4x.org"; x-sender="simon.cruanes.2007@m4x.org"; x-conformance=sidf_compatible; x-record-type="spf2.0" Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of SRS0=gmeT=PD=m4x.org=simon.cruanes.2007@bounces.m4x.org designates 129.104.30.34 as permitted sender) identity=mailfrom; client-ip=129.104.30.34; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="SRS0=gmeT=PD=m4x.org=simon.cruanes.2007@bounces.m4x.org"; x-sender="SRS0=gmeT=PD=m4x.org=simon.cruanes.2007@bounces.m4x.org"; x-conformance=sidf_compatible; x-record-type="spf2.0" Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of postmaster@mx1.polytechnique.org designates 129.104.30.34 as permitted sender) identity=helo; client-ip=129.104.30.34; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="SRS0=gmeT=PD=m4x.org=simon.cruanes.2007@bounces.m4x.org"; x-sender="postmaster@mx1.polytechnique.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DFAAAMRN1WliIeaIFdhAxtqhGSR4cSPBABAQEBAQEBARABAQEBCQsJCSEvgi2CFQEFI0sLEAsOEwQdAgIPBQ0kGBMSAod5AxIFCbBFihIDCoRHIgiKVII9hH0rgQ8FhhwMkHoIhWOGFYFrgjiMTIcMh0k3giscgUlpiT0BAQE X-IPAS-Result: A0DFAAAMRN1WliIeaIFdhAxtqhGSR4cSPBABAQEBAQEBARABAQEBCQsJCSEvgi2CFQEFI0sLEAsOEwQdAgIPBQ0kGBMSAod5AxIFCbBFihIDCoRHIgiKVII9hH0rgQ8FhhwMkHoIhWOGFYFrgjiMTIcMh0k3giscgUlpiT0BAQE X-IronPort-AV: E=Sophos;i="5.22,550,1449529200"; d="asc'?scan'208";a="206313615" Received: from mx1.polytechnique.org ([129.104.30.34]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-GCM-SHA384; 07 Mar 2016 10:09:01 +0100 Received: from nunchakus.loria.fr (nunchakus.loria.fr [152.81.10.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ssl.polytechnique.org (Postfix) with ESMTPSA id D21B6564A3B; Mon, 7 Mar 2016 10:09:00 +0100 (CET) Date: Mon, 7 Mar 2016 10:08:59 +0100 From: Simon Cruanes To: Malcolm Matalka Cc: Yotam Barnoy , Ocaml Mailing List Message-ID: <20160307090859.GF30630@nunchakus.loria.fr> References: <86oaaqahc1.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="7uYPyRQQ5N0D02nI" Content-Disposition: inline In-Reply-To: <86oaaqahc1.fsf@gmail.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) X-AV-Checked: ClamAV using ClamSMTP at svoboda.polytechnique.org (Mon Mar 7 10:09:01 2016 +0100 (CET)) X-Spam-Flag: No, tests=bogofilter, spamicity=0.000000, queueID=169ED564A3C X-Org-Mail: simon.cruanes.2007@polytechnique.org Subject: Re: [Caml-list] Question about Lwt/Async --7uYPyRQQ5N0D02nI Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, It seems that Lwt is more popular in the community outside JaneStreet than Async (if only by looking at its reverse dependencies on opam.ocaml.org). There has been posts about this, for instance http://rgrinberg.com/blog/2014/12/11/abandoning-async/ . However, if you're writing a library, it is good taste (if possible) to parametrize you code over an "IO" monad that will be easy to instantiate with either Async or Lwt (or the trivial blocking monad where 'a t =3D 'a and (>>=3D) x f =3D f x) along with the required IO primitives. Regarding general utility functions, if they do not perform IO or depend on (blocking) IO they can be used directly with Async/Lwt (unless they really take a very long time to complete). Le Mon, 07 Mar 2016, Malcolm Matalka a =C3=A9crit : > Yotam Barnoy writes: > > Hi all > > > > I'm thinking about my next project in OCaml, and I'm wondering how many > > users of OCaml currently use Lwt or Async regularly. > > > > One of the advantages of OCaml over Haskell (which I'm not crazy about)= is > > the fact that you don't have to constantly be stuck inside a monad. > > However, once you want to use these user-level threading libraries, you= 're > > essentially tied to a monad. It also means that the usage of any other > > monad from Lwt/Async code is out -- OCaml doesn't have the monad > > transformer infrastructure to layer monads easily as far as I can tell = (am > > I wrong?). I mean, even in Haskell using Monad Transformers is a pain (= IMO). > > > > Also, what happens to general utility functions that aren't rewritten f= or > > Async/Lwt -- as far as I can tell, being in non-monadic code, they will > > always starve other threads, since they cannot yield to another Async/L= wt > > thread. Is this perception correct? If so, this seems to imply that you > > either write your code to cooperate within these frameworks and suffer = the > > monad, or don't, and make it near-impossible for Lwt/Async users to make > > use of your code. > > > > I would like to get an idea of the usage level of these libraries, as w= ell > > as the burden of writing compatible code, any difficulties etc. Also, I= 'd > > like to get a sense of the domains that benefit from these libraries. S= ome > > domains (such as gaming) traditionally involve a continuous main loop, = and > > would thus only suffer from the additional overhead of queuing in these > > libraries. > > > > -Yotam >=20 > I mostly use Async. However, I think most usage of Lwt or Async > requires doing as little as possible in these frameworks and using them > to orchestrate other functions. For example, I usually try to separate > parsing of a network protocol from the reading and writing of the bytes. >=20 > --=20 > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs --=20 Simon Cruanes http://weusepgp.info/ key 49AA62B6, fingerprint 949F EB87 8F06 59C6 D7D3 7D8D 4AC0 1D08 49AA 62B6 --7uYPyRQQ5N0D02nI Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJW3UUpAAoJEErAHQhJqmK2LLEP/2l4/+44bGB2Stmjhxye9+oQ vu5uttXD3oOfXxBKWpjPRkcaRuYIAX1oaos+PyCPFHRbZ3qemY39j5aIT70zw5Mr 9/M6Sjoxf3g53xK0RRgwe+zML1Ofk8YeV6P9ZXT0EJJSGguWYp4GBe6pko2IN6j8 cLfUzs9rdYwX5TIhztlJIeBripT9Djk4CBukulP28K+vz8FU2EflbsfkiS3N+hnL QYjUsRWAovP9ELeeYm+Ck6FQTjK5SupxtscPkKv1lIR6MouA18rUs2xG9n5AgtSp ddsJnlGbcJ6O8Gy5Ibddms3X48aDauRC+epEFwYkgqtOTLrEr9SAVG4HSsCzKt+X aICEW0398tUhtlkXW96g6CWU286uusuI9qVgzH0GmrPpM1XoQN0VK+jqs+P5H6Cb lTCoqMnX+msJ5bxQQvTLEHAH5gw/dskVT/OAYCSLyTbNbFNawgF161a8hngp0D4g 3KuDh+Lp/2n9+Kpao8Mt0DpmtdW3p0hsUoVMeHCdJJblFBEeRqqIwXddlyhjxP0s 1GAN+PVblkPi6GUMlnn8WoJTg6ldqn3r1+YjMncTGvW3BsNidZZ9swVaG91Rh7ri Payn8rvqLtXWj5pUT2S27lRWbFCzPZ7syO/D1UXLIeTGl5erRldC9O+qsqkb4axJ Ud399R2NrniwZMyEj0Sj =EFZ6 -----END PGP SIGNATURE----- --7uYPyRQQ5N0D02nI--