Where has the map method on Optional moved? (original) (raw)
Sam Pullara sam at sampullara.com
Mon Feb 25 21:16:27 PST 2013
- Previous message: Initial spec review for Stream
- Next message: Where has the map method on Optional moved?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I've never been comfortable with this. I'm glad Jed is calling it out. Can we make Optional first class or remove it?
Sam
On Mon, Feb 25, 2013 at 9:12 PM, Jed Wesley-Smith <jed at wesleysmith.io> wrote:
Hi Paul,
You don't get a choice, it is a (or forms a) monad, you just removed the useful methods (map/flatMap aka fmap/bind). This leaves clients to implement them (or the functionality) in an ad-hoc and possibly buggy form themselves. It is a monad if there exists some pair of functions: A -> Option Option -> (A -> Option) -> Option The first is Optional.of, the second is currently: Optional a = … Optional b = … Function<A, Optional f = … if (a.isPresent) { b = f.apply(a.get()); } else { b = Optional.empty(); } rather than: Optional a = … Function<A, Optional f = … final Optional b = a.flatMap(f); cheers, jed. On 26 February 2013 00:12, Paul Sandoz <paul.sandoz at oracle.com> wrote: Hi Dhananjay,
It is not missing it was removed. java.util.Optional has a narrower scope that optional things in other languages. We are not trying to shoe-horn in an option monad. Paul. On Feb 23, 2013, at 12:27 AM, Dhananjay Nene <dhananjay.nene at gmail.com> wrote:
It seemed to be there on the Optional class in b61 but is missing now. Is there some way to run map/flatMap operations on an Optional?
Thanks Dhananjay
- Previous message: Initial spec review for Stream
- Next message: Where has the map method on Optional moved?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the lambda-libs-spec-observers mailing list