caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Dawid Toton <dawid.toton@uj.edu.pl>
To: caml-list@yquem.inria.fr
Subject: 'Nondeterministic' evaluation wrt exceptions
Date: Fri, 25 Jul 2008 16:29:47 +0100	[thread overview]
Message-ID: <4889F16B.3020903@uj.edu.pl> (raw)

Let's look at my OCaml program as a poset of function applications.
Some its elements throw exceptions.
I need to evaluate all applications except of those that 'Follow' 
exception-throwing ones.
This 'Follow' corresponds to the ordering in my poset.
Unfortunately standard tools allow only to do this with 'Follow' 
corresponding to some total order.
Could you give me some advice how to evaluate really all applications 
that precede throwing an exception?

----------
Full story

I have many similar programs that do calculations for me. Some steps are 
very computationally heavy. Every such function do_heavy_thing starts 
another process (on other computer) and throws an exception that means 
"the result will be available later". Everything that relies on this 
result of do_heavy_thing cannot be evaluated. And it won't be because I 
don't catch the exception.

So I run my programs repeatedly. I correct and extend them while 
heavy_thing is done somewhere else (usually for few days).
do_heavy_thing checks for the result. If it's finished at the moment of 
execution, it downloads the data and returns. Then the data undergoes 
some cheap transformations and some next do_heavy_thing function can be 
called.

Every time I execute the program I get some more useful output and 
"Fatal error: exception ..." message. So far this scheme worked very well.

This is basically breaking the calculation at some point with respect to 
a total order (the order of source code). Some calculations should be 
done in parallel, since there are many of them. I solved this problem 
with run_many adapter: firstly collect a list of heavy calculations, 
then execute them as a one node in the total order of evaluation.

Currently I hit the following problem: my new programs (call them 
'Calcs') are too complex to apply the evasion with run_many. So my 
latest calculations are done one-by-one. This is so bad, that I can 
spend several days in order to solve this in a systematical way.

These Calcs are managed by other set of OCaml tools. I have complete 
control over all the code. The tools already do tiny changes to Calcs 
with simple string operations, not real syntax extension. I hope some 
witty preprocessor can help.

I have no idea what code the syntax extension should produce. My first 
guess is to wrap everything in
 type 'a wrapped = Exception | Value 'a
and make all aplications evaluated. But this seems to be a big headache. 
Maybe this is well-known, already solved problem? Any ideas?

Dawid


             reply	other threads:[~2008-07-25 15:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-25 15:29 Dawid Toton [this message]
2008-07-25 15:46 ` [Caml-list] " Gabriel Kerneis
2008-07-25 16:20 ` Xavier Leroy
2008-07-25 19:29   ` Dawid Toton
2008-07-25 20:10     ` Christophe TROESTLER
2008-07-25 20:31     ` Zheng Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4889F16B.3020903@uj.edu.pl \
    --to=dawid.toton@uj.edu.pl \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).