
On Sat, 2009-03-28 at 12:51 +0300, Gregory Petrosyan wrote:
On Sat, Mar 28, 2009 at 10:53 AM, Ketil Malde
wrote: So the difference between an exception or an error type is mainly what you intend to do about it. There's no point in wrapping divisions in Maybe unless you actually are able to do something useful to recover from a zero denominator.
That is exactly the point I was trying to make.
When I write a code, I can't say in advance, in what way it will be used. So, for dealing with errors, I have to choose one way or another, mostly without that knowledge. When I'm using e.g. C++, it's easy: something like mantra "when in doubt, throw an exception" :-) combined with RAII, works good (but not ideal, of course).
So, I'll ask again: when I program in Haskell, what mechanism should I use?
If you don't know, use a (true) exception. That is, Left or Exception or throwIO. Only use error or throw when you *know* the condition is un-recoverable. jcc