Hacker News new | ask | show | jobs
by andolanra 5433 days ago
There is a slight advantage to Haskell/Scala/Caml's Maybe versus the nullable type system used in Vala and Groovy and so forth. If you have a hash table whose values are (e.g.) Integers, looking up a key would return a Maybe<Integer> (because there's no guarantee the key exists.) If you wanted to have null values in the hash table, then the values would be Maybe<Integer> and looking up a key would return a Maybe<Maybe<Integer>>, which could be Nothing (because the key was not present in the table) or Some<Nothing> (because the key was present and a null value was stored in the table) or Some<Some<x>> where x is an Integer. As far as I know, nullable type systems don't allow Integer?? as a type. Still—it is a huge step above the nothing you're offered in other languages.