Re: Use unsafePerformIO to catch Exception?

From: Jules Bean
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.
I could follow the rest of this, but I don't understand why 'head' is necessary. Couldn't you always replace it with a case statement, with undefined on [] if necessary? I won't deny that it's extremely useful, though! John Lato

2009/03/27 John Lato
From: Jules Bean
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.
I could follow the rest of this, but I don't understand why 'head' is necessary. Couldn't you always replace it with a case statement, with undefined on [] if necessary?
How would that be any different from head? -- Jason Dusek

On Fri, Mar 27, 2009 at 9:51 PM, Jason Dusek
2009/03/27 John Lato
: From: Jules Bean
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.
I could follow the rest of this, but I don't understand why 'head' is necessary. Couldn't you always replace it with a case statement, with undefined on [] if necessary?
How would that be any different from head?
That's what I'm asking. It was claimed that 'head' is a necessary function, but I don't see why.

On Fri, 27 Mar 2009, Jason Dusek wrote:
2009/03/27 John Lato
: I could follow the rest of this, but I don't understand why 'head' is necessary. Couldn't you always replace it with a case statement, with undefined on [] if necessary?
How would that be any different from head?
The psychological advantage is, that you had to do something with the case [] and programmers hopefully hesitate more to write 'error' than to write 'head'. :-) Practically, if you have no better idea than writing 'error', you would write an error message that is more specific than "head: empty list", which makes debugging easier.
participants (3)
-
Henning Thielemann
-
Jason Dusek
-
John Lato