Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[OSR] Exceptionless error management
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-01-31 (20:26)
From: David Teller <David.Teller@u...>
Subject: Re: [Caml-list] [OSR] Exceptionless error management

On Thu, 2008-01-31 at 21:03 +0100, Bünzli Daniel wrote:
> Le 31 janv. 08 à 15:09, Andrej Bauer a écrit :
> > I have become to prefer option types as return values (as opposed to  
> > exceptions), but I admit it can be annoying to always consider both  
> > possibilities, especially if you know that "None" won't happen.
> Maybe it is a point of view, you are fed up of considering both  
> possibilites while I'm personally fed up of writing
> match try Some (f x) with e -> None with
> | None -> ..
> | Some v -> ...
> Because I need tail recursive functions.

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 = 
      Success ( Lazy.force e )
      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 ?


David Teller
 Security of Distributed Systems
 Angry researcher: French Universities need reforms, but the LRU act
brings liquidations.