That would be inconsistent with the other types in FJ. There's no advantage to that over using Option other than compatibility with code that uses Optional, for which a couple of conversions can be provided. If they do it right then I would expect us to drop Option but FJ is not the kind of library that makes compromises, it should instead be the library that does everything as well as is possible in Java. That said it's not exactly a translation of Haskell's prelude.
Proper extension methods would let us add flatMap and map to Optional and get on with life. On Thu, Nov 1, 2012 at 11:21 PM, clay <[email protected]> wrote: > But you wouldn't lose any functionality at all, you would merely lose the > more convenient syntax > > instead of class function syntax: > > optObj.flatMap((a) -> ...); > > you would use external static function syntax: > > flatMap(optObj, (a) -> ...); > > On Thursday, November 1, 2012 8:00:01 PM UTC-5, Ricky Clarkson wrote: >> >> It is unlikely that we will drop Option in favour of Optional in >> Functional Java, as that would be a step backwards for the library if >> Optional does not gain flatMap etc. There will almost certainly be a >> compatibility layer. >> >> As an aside, it's amazing how small an amount of code we're really >> talking about. I just implemented Option and List including map and >> flatMap in JavaScript for fun on the way home from work (and missed my >> stop!). >> >> On Thu, Nov 1, 2012 at 9:39 PM, clay <[email protected]> wrote: >> > OK, I wrote Optionals for JDK8 which adds static functions map, flatMap, >> > and >> > toIterable >> > >> > http://pastebin.com/HZ1suSRt >> > (I would probably adjust the generics type boundaries if this was a >> > serious >> > effort) >> > >> > So that these work: >> > >> > map(optObj, (o) -> ...); >> > flatMap(optObj, (o) -> ...); >> > for (T t : toIterable(optObj)) { ... } >> > >> > For at least the first two, C#-style extension methods would offer more >> > natural syntax, but I don't think that is a big deal: >> > >> > optObj.map((o) -> ...); >> > optObj.flatMap((o) -> ...); >> > >> > The major downside is that this will be another third-party add-on >> > library >> > and not built-in to the core standard library. >> > >> > Will third party libraries -- mainly Functional Java but also others >> > like >> > Atlassian Fugue -- standardize on the JDK8 option and use static methods >> > for >> > the omitted features or will they continue to use completely separate >> > Option >> > class implementations? >> > >> > -- >> > You received this message because you are subscribed to the Google >> > Groups >> > "Java Posse" group. >> > To view this discussion on the web visit >> > https://groups.google.com/d/msg/javaposse/-/9-5GnOv9VGUJ. >> > >> > To post to this group, send email to [email protected]. >> > To unsubscribe from this group, send email to >> > [email protected]. >> > For more options, visit this group at >> > http://groups.google.com/group/javaposse?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Java Posse" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/javaposse/-/2jhSx9IrHTEJ. > > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/javaposse?hl=en. -- You received this message because you are subscribed to the Google Groups "Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
