I am trying to understand reasons behind different Option/Optional semantics in probably 3 most used implementations in Java ecosystem: Java 8, Functional Java and Guava.
Considering following three snippets.
java.util.Optional.of(100).map(i -> null)
results inOptional.empty
.fj.data.Option.some(100).map(i -> null)
results inSome(null)
.com.google.common.base.Optional.of(100).transform(i -> null)
resultsNullPointerException
.
What are the reasons behind 3 choices? If appicable, what can be considered most "pure" or "correct" from functional programming point of view? For example, in terms of viewing Option
type as monad, what would be most correct; or what can be considered most composable? It would also interesting to know how this is handled in functional languages that allow nulls.