Erroring and handling exceptions
Haskell very intentionally does not have a null
/None
/nil
value like many popular languages have, both strongly typed (Java) or not (Perl). Null values are exceptionally bad for program safety. Null values are not expressed in types, giving nulls no choice but to hide from the unsuspecting programmer and pop into sight in production.
Nulls are one of the main causes of bugs and security holes in today's software, which is why Haskell has opted for a no-null policy. This might sound restrictive at first, but actually the alternative representations for possibly failing computations in Haskell are various and rich.
First, there are infinite ways to embed the possibility of failing into the datatype: Maybe, Either, YourAwesomeDataType
, and so on.
Second, with the wonderfully extensive abstraction machinery in Haskell we can compose and recover from failing situations on a very high level. Although these functors, monoids, monads, and whatnots have scarily...