4 ms·
Where this can directly been seen in Java is the Optional class which has the methods you describe as instance methods. Though Java has no syntactic sugar for m
by chopin 4y ago
Where this can directly been seen in Java is the Optional class which has the methods you describe as instance methods. Though Java has no syntactic sugar for monads this allows chaining expressions (which I think in Haskell would be bind() chains). Java streams behave similarly (and form a kind of monad around Collections).
Having monad (or functor) functions (flatMap, map,...) as static functions has the disadvantage that you can't chain them well.