[Haskell-cafe] exceptions vs. Either

MR K P SCHUPKE k.schupke at imperial.ac.uk
Wed Aug 4 04:57:44 EDT 2004

>mins = map ((\(x:_)->x).sort)

maybe what you meant was:

	case sort x of
	   (x:_) -> ... do whatever with x ...
	   _ -> ... do failure conition ...

As I said, if you can _guarantee_ non failure I guess head is okay, but the
fact that this thread started with the observation that the error produced
by head is difficault to track dow
n we must conclude that programmers make mistakes and cannot be trusted to
make such guarantees .... Hence my suggestion to use the type system.

Effectively the 'case' forms a guarantee of non-emtyness for the stuff in 
the case... but you cannot pass this guarantee into functions like 'head'

Using the type system to encode such things allows this 'guarantee' to
be passed into functions... 


More information about the Haskell-Cafe mailing list