caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* 'Nondeterministic' evaluation wrt exceptions
@ 2008-07-25 15:29 Dawid Toton
  2008-07-25 15:46 ` [Caml-list] " Gabriel Kerneis
  2008-07-25 16:20 ` Xavier Leroy
  0 siblings, 2 replies; 6+ messages in thread
From: Dawid Toton @ 2008-07-25 15:29 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-07-25 20:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-25 15:29 'Nondeterministic' evaluation wrt exceptions Dawid Toton
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

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).