From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q0MFIUus001241 for ; Sun, 22 Jan 2012 16:18:31 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlAHAMknHE+CcUBTaWdsb2JhbABDFqxBgW8NBQYJCRQlgXIBAQUMJgEFQAEQCxgJFg8JAwIBAgFFBg0BBwEBiAC3KIwmBIg7kjSNFg X-IronPort-AV: E=Sophos;i="4.71,551,1320620400"; d="scan'208";a="128417032" Received: from sigma957.cis.mcmaster.ca ([130.113.64.83]) by mail4-smtp-sop.national.inria.fr with ESMTP; 22 Jan 2012 16:18:24 +0100 Received: from Gorash7.UTS.McMaster.CA (Gorash7.UTS.McMaster.CA [130.113.196.61]) by sigma957.cis.mcmaster.ca (8.13.7/8.13.7) with ESMTP id q0MFIGd9014124; Sun, 22 Jan 2012 10:18:21 -0500 (EST) Received: from cgpsrv2.cis.mcmaster.ca (univmail.CIS.McMaster.CA [130.113.64.46]) by Gorash7.UTS.McMaster.CA (8.13.7/8.13.7) with ESMTP id q0MFI86C004443; Sun, 22 Jan 2012 10:18:08 -0500 Received: from [173.32.159.3] (account carette@univmail.cis.mcmaster.ca HELO [192.168.2.100]) by cgpsrv2.cis.mcmaster.ca (CommuniGate Pro SMTP 5.2.12) with ESMTPSA id 389910543; Sun, 22 Jan 2012 10:18:08 -0500 Message-ID: <4F1C28B5.7020901@mcmaster.ca> Date: Sun, 22 Jan 2012 10:18:13 -0500 From: Jacques Carette Organization: McMaster University User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: Xavier Leroy CC: caml-list@inria.fr References: <4F196092.7060707@dogguy.org> <4F1BE3B1.3040704@inria.fr> In-Reply-To: <4F1BE3B1.3040704@inria.fr> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-PMX-Version-Mac: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.1.22.150019 X-PerlMx-Spam: Gauge=IIIIIIII, Probability=8%, Report=' BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_2000_2999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, DATE_TZ_NEG_0500 0, __ANY_URI 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CP_URI_IN_BODY 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MOZILLA_MSGID 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __URI_NO_MAILTO 0, __URI_NO_WWW 0, __URI_NS , __USER_AGENT 0' X-Spam-Flag: NO Subject: Re: [Caml-list] Custom let bindings That discussion was extremely enlightening. I read every single message carefully, then thought about it for a while, THEN I composed this message. Then thought some more before sending it. There is one place where things seem to have gone off the rails: Lwt's concurrency pattern is *not* a (generic) monadic pattern. What Lwt does here is to overload Caml's "let .. and ..." to mean (essentially) Classen's 'Fork' monad transformer [1]; one could probably interpret it via MonadZip as well. It is also worthwhile remembering that, in Haskell concurrency is not handled via monads at all, and that parallelism is handled monadically is very recent [2]. It is Lwt which is over-reaching here, and it is not a flaw in Nicolas's proposal, or Alain's variant. There are sufficiently many use-cases for "sequential bind" to have a special syntax for that; a special syntax for parallel bind can be developed later, as a further extension [esp. as Jérémie found a 23:1002 ratio of parallel bind to sequential bind amongst users of Lwt!]. As one heavy user of monads, and a co-author of pa_monad, I can definitely say that the original let! proposal would be extremely useful to me. If it could be made to mesh nicely with a (generic) monadic interface, that would be sufficient. As Xavier's extensive code shows, monads work now in OCaml. The only question that remains is a nice bit of syntactic sugar that 'fits' OCaml, like the 'do' notation fits Haskell. To make a specific proposal: why not adopt the pa_monad syntax (or variant thereof)? The implementation would have to be modernized to use all the wonderful 3.12 features, but otherwise seems to fit the other use cases rather well. On 22/01/2012 5:23 AM, Xavier Leroy wrote: > In the end, we decided that none of the proposals is something we can > commit on and put (forever) in the core language. This is one of the > cases that is currently best handled by Camlp4 syntax extensions, > either specific to a monad (Lwt) or more general (pa_monad). Note that pa_monad has not been certified to work properly with 3.12. I have tried to do some further work with Camlp4 (which required changes to Camlp4 itself), and was not successful - the bootstrapping steps are simply too fragile. pa_monad is, unfortunately, likely to bit-rot over time. As a stop-gap, I think I will ask Oleg which patch he prefers (Nicolas' or Alain's), and get that pushed onto ber-metaocaml, so that part of my work can benefit from this. [I have some 'pure' OCaml code which will, unfortunately, have to do without.] Jacques C. [1] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.39.8039 [2] http://research.microsoft.com/~simonpj/papers/parallel