From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 1A66EBC6C for ; Fri, 1 Feb 2008 00:49:47 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAP/soUfUnw7Ulmdsb2JhbACCNo1pAQEBAQcEBgcKEQeaSA X-IronPort-AV: E=Sophos;i="4.25,287,1199660400"; d="scan'208";a="22036428" Received: from ptb-relay01.plus.net ([212.159.14.212]) by mail4-smtp-sop.national.inria.fr with ESMTP; 01 Feb 2008 00:49:47 +0100 Received: from [80.229.56.224] (helo=beast.local) by ptb-relay01.plus.net with esmtp (Exim) id 1JKjA9-0006Ji-Uc for caml-list@yquem.inria.fr; Thu, 31 Jan 2008 23:49:46 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] [OSR] Exceptionless error management Date: Thu, 31 Jan 2008 21:35:26 +0000 User-Agent: KMail/1.9.7 References: <1201811141.6565.21.camel@Blefuscu> In-Reply-To: <1201811141.6565.21.camel@Blefuscu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200801312135.27010.jon@ffconsultancy.com> X-Plusnet-Relay: b7eace88ac40e508db538f534a3d0148 X-Spam: no; 0.00; trivial:01 camlp:01 stdlib:01 scrap:98 frog:98 polymorphic:01 idiom:01 wrote:01 exception:01 caml-list:01 functions:01 variant:02 lazy:02 lazy:02 rarely:02 On Thursday 31 January 2008 20:25:41 David Teller wrote: > What about a generic > > type result 'r 'e = > > | Success of 'r (**The operation was a success*) > | Failure of 'e (**The operation was a failure*) > > let purify e = > try > Success ( Lazy.force e ) > with > exc -> Failure exc > > ? > > With one such mechanism we can nearly automatically transform > exception-returning expressions into exceptionless management. We could > complete this with a trivial amount of Camlp4 code to avoid the call to > "lazy / Lazy.force". > > What do you think about this solution ? Scrap the explicitly-declared sum type for a polymorphic variant, lazy value for a function and catch only a specific exception and you've got the approach that I already use. You can factor this out but this is so rarely used that it isn't worth it. If the stdlib had common IO functions I wouldn't use that idiom at all. -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/products/?e