exporting functions which raise exceptions

Simon Marlow simonmar at microsoft.com
Thu Jun 13 08:11:12 EDT 2002

> > When this issue was discussed earlier, I think, SimonM pointed out
> > that (especially in the context of concurrency) it is hard to define
> > what exactly is supposed to happen with such exceptions. 
> I'm not sure I see the difficulty - but I'll go ahead and make up my
> own solution (which will probably be much like what GreenCard does...)

You probably want the caller to handle the exception, and the caller is
probably a C function.  So the right way to do it is to catch the
exception in Haskell and return some kind of error value to the caller;
this is best done by the programmer, since there are plenty of choices
for the mechanism used to pass the error value back.  The default
behaviour of terminating the program (and reporting the exception, of
course) is the safest thing to do in the absence of any alternative


More information about the FFI mailing list