On May 4, 2010, at 12:31 , Gregory Crosswhite wrote:
On May 4, 2010, at 5:22 AM, John Lato wrote:
"Crashing at the point of the error" isn't necessarily useful in
Haskell due to lazy evaluation.  The code will crash when the result
of the partial function is evaluated, which may be quite far away (in
terms of function calls) from where the programmer would expect.

But hypothetically, suppose that you decided to use safeSecondElement anyway; now you have to deal with a Nothing in your code. Since, again, you don't know how to recover from this (as if you did, you wouldn't have gotten a Nothing in the first place), the only thing you can do is propagate it through the calculation, until it reaches someone who can recover from it, which means that now your whole calculation has to be muddled up with Maybe types wrapping every result purely to capture the

Using Maybe as a monad helps a lot here.

possibility of a bug (or hardware fault, I suppose). If your program relied on this calculation, then it *still* has no choice but to terminate, and it *still* doesn't know where the error occurred

It occurs to me that combining Error and Writer gives you traceback.

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH


Attachment: PGP.sig
Description: This is a digitally signed message part

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to