Re:Letter to a Young Haskell Enthusiast
by yawaramin on Saturday August 02, 2014 @03:13AM
(#8124301)
You shouldn't consider this to be a break. Sure, it's crappy API design--lots of people have pointed out that `head` should return a `Maybe` because an empty list doesn't have a head--but triggering an error in a partial function is not a break. Taking the head of an empty list is no more a break than dividing something by zero.
Re:Letter to a Young Haskell Enthusiast
by dragonwriter on Saturday August 02, 2014 @01:23PM
(#8125338)
> You shouldn't consider this to be a break.
I can't see any reasonable definition of "break" for this context for which that is valid; its exactly the same kind of breakage that strong type checking reduces the incidence of in Haskell compared to dynamic languages -- runtime errors resulting from a function call not being able to complete without error for all inputs that the language will allow to be passed to it.
> Taking the head of an empty list is no more a break than dividing something by zero.
I agree; both are clearly examples of things that can cause a program to break.
Good point, but in general I think it's fair to say that if Java's type system prevents the type of breakages that are possible in ruby 50% of the time, Haskell prevents 99.9% of such breakages.
A program that compiles in Haskell can still break, consider: