top | item 42980505

(no title)

blastonico | 1 year ago

> The method names are more intuitive: e.g., then instead of map

But map makes total sense, considering that maybe is a monad.

discuss

order

edflsafoiewq|1 year ago

Rather than monads, map is more likely to be familiar from sequences, and an optional is just a sequence with length < 2.

eru|1 year ago

Well, monads get their map from functors, and they call it 'map' (or fmap) because of map on sequences.

Jaxan|1 year ago

I would expect different types of map and then:

    map :: (a -> b) -> Maybe a -> Maybe b
    then :: (a -> Maybe b) -> Maybe a -> Maybe b
Although for Maybe these are not too different.

coin|1 year ago

“then” is definitely less intuitive

puchatek|1 year ago

Intuition is in the eye of the beholder

eru|1 year ago

Well, it only needs to be a functor (in the Haskell sense) for map to make sense.

(Of course, all monads are also functors.)

voidhorse|1 year ago

True, but I would not be surprised if the vast majority of Java programmers have no clue what a monad is.

chii|1 year ago

> no clue what a monad is.

which is a good opportunity to introduce said nomenclature, and ideas to them, rather than renaming said method to something more "palatable".

xigoi|1 year ago

You don’t need to mention monads, just imagine an Optional as a list with at most one element.