From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p8FC9ZnJ013422 for ; Thu, 15 Sep 2011 14:09:36 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtgFAA7qcU7VuiYS/2dsb2JhbABChAxJoHyBfHiBUwEBBQwXBFIQCQIaAiYCAiwrBi6HXqUQkV8OgR6EN4ERBKRz X-IronPort-AV: E=Sophos;i="4.68,387,1312149600"; d="scan'208";a="119945862" Received: from solaria.dimino.org ([213.186.38.18]) by mail1-smtp-roc.national.inria.fr with ESMTP; 15 Sep 2011 14:09:36 +0200 Received: from aurora (localhost.localdomain [127.0.0.1]) by solaria.dimino.org (Postfix) with ESMTP id 9293E80048; Thu, 15 Sep 2011 14:09:35 +0200 (CEST) Received: by aurora (Postfix, from userid 1000) id E55153FF79; Thu, 15 Sep 2011 14:09:36 +0200 (CEST) From: =?ISO-8859-1?Q?J=E9r=E9mie?= Dimino To: Mehdi Dogguy Cc: caml-list@inria.fr Date: Thu, 15 Sep 2011 14:09:36 +0200 In-Reply-To: <4E71CDB8.5020704@dogguy.org> References: <20110913183714.GA15241@yeeloong.happyleptic.org> <4E71CDB8.5020704@dogguy.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.0.3- Message-ID: <1316088576.28210.8.camel@aurora> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p8FC9ZnJ013422 Subject: Re: [Caml-list] Lwt and exceptions 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. -- Jérémie