I can definitely see :)

Option obviously has to be iterable as well, so that it composes cleanly
with other collections.

Then we can move to a model where composed functions are pushed through
data instead of the other way round; leave all that hairy cyclomatic
complexity in the dust where it rightly belongs!


On 25 October 2012 20:13, Cédric Beust ♔ <[email protected]> wrote:

>
> On Tue, Oct 23, 2012 at 5:22 PM, clay <[email protected]> wrote:
>
>> Why is there no flatMap?
>
>
> Would you really be satisfied if Optional had flatMap, though?
>
> Think about it carefully.
>
> To me, the main benefit of flatMap is composability. With flatMap, I can
> pass my Optional and other monadic values across a flow of transformations
> without ever having to drop down to raw values.
>
> And here is the rub: Optional would be the only type in the JDK that has
> this property. It would be a bit like being the only person on the planet
> with a fax machine. If all that I can do is composing Optionals with other
> Optionals, the value is severely limited. Once/if Optional gains flatMap,
> won't you want List to get it as well? And Map? And TreeSets?
>
> You see where this is going...
>
> --
> Cédric
>
>
-- 
Kevin Wright
mail: [email protected]
gtalk / msn : [email protected]
quora: http://www.quora.com/Kevin-Wright
google+: http://gplus.to/thecoda
<[email protected]>
twitter: @thecoda
vibe / skype: kev.lee.wright
steam: kev_lee_wright

"My point today is that, if we wish to count lines of code, we should not
regard them as "lines produced" but as "lines spent": the current
conventional wisdom is so foolish as to book that count on the wrong side
of the ledger" ~ Dijkstra

-- 
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.

Reply via email to