Comment

Comment by giornogiovanna

Yeah, I don't know why Prelude.head doesn't return a Maybe. Anyway, the point stands.

• In Java forgetting to check for null will crash your program.

• In C, forgetting to check for NULL will lead to undefined behavior.

• In Haskell, you either have to (a) check for Nothing, or (b) explicitly say "crash the program if this is Nothing" by using a function like fromJust or head, which internally does (a). This is always an improvement over C, and often an improvement over Java.

Side note: I like Rust's convention of consistently naming these might-crash-your-program methods "unwrap" and "expect".

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton