On Nov 15, 2006, at 3:21 AM, [EMAIL PROTECTED] wrote:


Donald Bruce Stewart wrote:
So all this talk of locating head [] and fromJust failures got me
thinking:

    Couldn't we just use rewrite rules to rewrite *transparently*
    all uses of fromJust to safeFromJust, tagging the call site
    with a location?

I'm sorry for shifting the topic: I'm wondering if, rather than trying
to make an error message more informative, we ought to make sure that
no error will ever arise?
...
This topic has been discussed at length on this list. It seems that
the discussion came to the conclusion that eliminating head of
the empty list error is possible and quite easy in Haskell.

http://www.haskell.org/pipermail/haskell-cafe/2006-September/ 017915.html

But this code contains a function with_non_empty_list (or perhaps with_nonempty_list or withNonemptyList or...) which has the same confusing failure mode as the examples under discussion. Fundamentally, if we try to package up "check for failure" in a function, whether the function does something useful as well (head, tail, fromJust) or not (withNonemptyList), we miss out on useful contextual information when our program fails.

In addition, we have this rather nice assembly of functions which work on ordinary lists. Sadly, rewriting them all to also work on NonEmptyList or MySpecialInvariantList is a nontrivial task.

Which isn't to say that I disapprove of this style: check your invariants early, maintain them as you go. I'm quite enjoying the escH paper, but I get through about a column per day between compiles. :-)

-Jan-Willem Maessen



Attachment: smime.p7s
Description: S/MIME cryptographic signature

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

Reply via email to