[Haskell-cafe] Haskell and the Software design process

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Fri May 7 21:10:58 EDT 2010


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] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH


-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100507/ab1e7083/PGP.bin


More information about the Haskell-Cafe mailing list