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 p8FCXKSh014880 for ; Thu, 15 Sep 2011 14:33:21 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsUBAGzvcU6GnQCBk2dsb2JhbABDhAxJongUAQEBAQkJCwkUAyOBUwEBBQwXBAsBRQEQCQIYAgIFFgsCAgkDAgECAUUGDQEHAhesa5FfgSyEN4ERBJNHhRyMEA X-IronPort-AV: E=Sophos;i="4.68,387,1312149600"; d="scan'208";a="109191017" Received: from shiva.jussieu.fr ([134.157.0.129]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 15 Sep 2011 14:33:15 +0200 Received: from hydrogene.pps.jussieu.fr (hydrogene.pps.jussieu.fr [134.157.168.1]) by shiva.jussieu.fr (8.14.4/jtpda-5.4) with ESMTP id p8FCWaRL086413 ; Thu, 15 Sep 2011 14:32:37 +0200 (CEST) X-Ids: 164 Received: from [134.157.168.19] (potassium.pps.jussieu.fr [134.157.168.19]) by hydrogene.pps.jussieu.fr (Postfix) with ESMTP id 6BC9EC3371; Thu, 15 Sep 2011 14:33:13 +0200 (CEST) Message-ID: <4E71F089.8010109@dogguy.org> Date: Thu, 15 Sep 2011 14:33:13 +0200 From: Mehdi Dogguy User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1.16) Gecko/20110506 Iceowl/1.0b1 Icedove/3.0.11 MIME-Version: 1.0 To: =?UTF-8?B?SsOpcsOpbWllIERpbWlubw==?= CC: caml-list@inria.fr References: <20110913183714.GA15241@yeeloong.happyleptic.org> <4E71CDB8.5020704@dogguy.org> <1316088576.28210.8.camel@aurora> In-Reply-To: <1316088576.28210.8.camel@aurora> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Miltered: at jchkmail.jussieu.fr with ID 4E71F08A.001 by Joe's j-chkmail (http : // j-chkmail dot ensmp dot fr)! X-j-chkmail-Enveloppe: 4E71F08A.001/134.157.168.1/hydrogene.pps.jussieu.fr/hydrogene.pps.jussieu.fr/ Subject: Re: [Caml-list] Lwt and exceptions On 15/09/2011 14:09, Jérémie Dimino wrote: > Le jeudi 15 septembre 2011 à 12:04 +0200, Mehdi Dogguy a écrit : >> I guess, not (and it has been answered already). In fact, I was wondering >> if Lwt's authors would be against adding a function like: >> >> let wrap f x = try Lwt.return (f x) with e -> Lwt.fail e >> >> It is stupid, trivial, etc… but looks what we need most of the time, no? > > Yes, it seems useful. But should it be: > > val wrap : ('a -> 'b) -> 'a -> 'b t > > or: > > val wrap : (unit -> 'a) -> 'a t > > ? > > I would tend for the second solution because if you are wrapping a > function that takes multiple arguments you are going to write: > > wrap (fun () -> f x y z) () > > anyway. Plus maybe wrap1, wrap2, ..., wrapn for a reasonable value of n. > Sure. Thanks for considering. Any of the above proposals would be fine for me :) -- Mehdi Dogguy مهدي الدڤي http://dogguy.org/