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



-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to