Option in Java 8

Brian Goetz brian.goetz at oracle.com
Thu Oct 11 07:54:13 PDT 2012

There was a long thread on this recently on lambda-dev.  You should read the archives.

The implementation is currently very much an approximation.  However, bear in mind that the goal for Option in Java may not be to create an Option monad.  So the experience of other languages may or may not be applicable.  

On Oct 11, 2012, at 3:27 PM, Mario Fusco wrote:

> Hi all,
> a couple of days ago I posted an article about how we could possibly
> implement and use an Option monad in Java 8:
> http://java.dzone.com/articles/no-more-excuses-use-null
> Now, a friend of mine just found that you are already implementing
> something very similar:
> http://hg.openjdk.java.net/lambda/lambda/jdk/file/700bcae6d1da/src/share/classes/java/util/Optional.java
> I'd be very happy to have an Option (and possibly a Validation) monad in
> Java 8. However, I don't know if that is the last implementation available,
> but if so I have to admit that I am a bit disappointed about it. The first
> improvements that comes to me in mind are:
> 1. it should be an abstract class with 2 concrete implementations
> 2. a flatMap method would be very useful
> 3. it could implement the Iterable interface
> What do you think about that?
> Mario

More information about the lambda-dev mailing list