[Haskell-cafe] exceptions vs. Either

MR K P SCHUPKE k.schupke at imperial.ac.uk
Wed Aug 4 07:54:23 EDT 2004

>No, I don't think so.  I only want the bug to be reported   

I think preventing the bug using the type system if possible is a good
idea... something that should be encouraged!

>and not a "corner case" that should be "handled".

So if the list depends on user input is not the empty list a corner
case of the function on user input?

>write small leaf functions like these with an implicit file/line

This is a good idea - If I have given the impression I am opposed to it 
then I have not expressed myself very well. I just think where this can
be avoided using the type system in the first place is an even better
idea. Design by contract is the way forward for large complex systems, 
and where that contract can be expressed using the type system is
a selling point for Haskell in such applications.

>It seems difficult to generalize this, though.

Again for read you can use "reads"...

Sven Panne said:

"reads" is probably what you are looking for:

    Prelude> (reads :: ReadS Integer) ""
    Prelude> (reads :: ReadS Integer) "a"
    Prelude> (reads :: ReadS Integer) "2"
    Prelude> (reads :: ReadS Integer) "123blah"


More information about the Haskell-Cafe mailing list