4 ms·
> you have to be wary of using Java and .NET types which are still prone to NPEs Java8 optionals are a maybe monad http://stackoverflow.com/a/19932439/4658666
by wcummings 11y ago
> you have to be wary of using Java and .NET types which are still prone to NPEs
Java8 optionals are a maybe monad
http://stackoverflow.com/a/19932439/4658666 http://stackoverflow.com/a/19932439/4658666
- quchen 11y agoI think your post only takes non-null values into account, which is what OP seems to talk about. What would this code do? Optional<Int> foo = null; foo.flatMap(x -> Optional.of(x)); Obeying the Monad laws would mean getting null as a result, via `m.flatMap(x -> Optional.of(x)) = m` for all m (or `m >>= pure = m` if you prefer Haskell syntax).
- deleted 11y ago[deleted]