[Haskell-cafe] Use unsafePerformIO to catch Exception?

Jules Bean jules at jellybean.co.uk
Fri Mar 27 07:51:46 EDT 2009

wren ng thornton wrote:
> The type of head should not be [a] -> a + Error, it should be (a:[a]) -> 
> a. With the latter type the compiler can ensure the precondition will be 
> proved before calling head, thus eliminating erroneous calls.

Yes, but you know and I know that's not haskell.

I'm talking about haskell.

In haskell - a language which does not fully support dependent types - 
head is both necessary and useful.

> It's a static error, detectable statically, and yet it's deferred to the 
> runtime. I'd much rather the compiler catch my errors than needing to 
> create an extensive debugging suite and running it after compilation.

It is not detectable statically. It is only detectable statically for a 
class for programs.

Admittedly, for that class of programs, ndm's fine tool "Catch" is a 
very clever thing.

 > Is this not the promise of purity?

No. Purity and partiality are orthogonal. Nobody promised pure languages 
would be total.

> Functions like uncons and viewL are nicer (because they're safe), but 
> they can have overhead because they're unnecessarily complete (e.g. the 
> Maybe wrapper can be avoided if we know a-priori that Just will be the 
> constructor used).

uncons and viewL are totally irrelevant.

They're just a convenient syntax around case matching.


More information about the Haskell-Cafe mailing list