On Tue, Dec 19, 2006 at 09:47:14PM +0100, Eric Y. Kow wrote:
> On Sun, Dec 17, 2006 at 13:24:33 -0800, David Roundy wrote:
> > +                        [_] -> error "Cannot rename a file or directory 
> > onto itself!"
> 
> Which is better here, fail or error?

I believe we aren't in a monad, so fail isn't an option.

> I don't think I have a very strong grasp of failure/errors.  I always
> feel uncomfortable on same level using error to indicate something going
> wrong (as opposed to a bug) [this porridge is too hot].  Then again the
> notion of failure is way more general than just "things going wrong"
> (consider Maybe), so that can't be quite right either...  [this porridge
> is too cold] and then there's exceptions, which I still haven't
> completely worked into my world view... and which, in any case does not
> seem appropriate for this.

Yeah, it's usually preferable to use fail for a user-viewable error, since
you know when it'll trigger (when it's executed, instead of lazily much
later).  In this case error is okay since one can easily examine the code
flow to make sure the error message is timely.

Fundamentally, error and fail trigger the same exception, so it's only a
question of timing.
-- 
David Roundy
http://www.darcs.net

Attachment: signature.asc
Description: Digital signature

_______________________________________________
darcs-devel mailing list
[email protected]
http://www.abridgegame.org/cgi-bin/mailman/listinfo/darcs-devel

Reply via email to