
ketil:
Aaron Tomb
writes: Huh? Type safety buys [...] nothing about dereferencing null pointers, which are the moral equivalent of Nothing.
What type safety buys you, in my mind, is that Nothing is only a valid value for explicit Maybe types. In cases where you don't use Maybe, the "null" situation just can't occur. In languages with null pointers, any pointer could possibly be null.
To write Haskell that is obviously safe, you need to check all cases of algebraic data types - both Just and Nothing. To do something similar in C, you need to check every pointer for NULL.
The great thing about Maybe is that once I've checked it isn't Nothing, I can extract the value and dispense with further checks.
foo mbx = maybe default (bar x) mbx
And GHC will warn me when I forget to check all cases, and prevent me from compiling at all, if I don't do any check. -- Don