I am wondering what exception/error and random classes I should use for my application.
The application will be doing Monte Carlo backtracking search. I want it to be multithreaded and run on all four cores on my MacBook.
I need detailed error messages in order to investigate errors. So I will throw errors or exceptions, then catch them in lower functions and annotate them with the parameters or computations within the lower function, then re-throw until finally the exception pops into the terminal.
Because it's multi-threaded, at least some parts will needs to be in IO. Also, because it's a Monte Carlo algorithm it will need to make pseudorandom choices.
Perhaps I should put everything in the IO monad? This will give me access to threads and the standard generator seed. But how about throwing, catching/rethrowing exceptions in IO? I have done this in pure code before: not sure if it's better to do it that way, in which case I could put some kind of state monad to hold the random seed together with an error monad and IO at the core of the monad stack.
Any advice welcome.
D