scala - What is monad analog in Java? -


i know in scala , many other functional languages there monads interface realization(for example in scala flatmap[t] , unit[t] methods) there java-style interfaces monad?

there 2 problems representing monads in java:

flatmap needs operate on function returns (same) specific monad, , java's type system cannot express that.

unit kind of static method in java terms, because creates monad instance generic value. java 8 has static methods on interfaces, abstract monad interface cannot know implementation, have use factory method somewhere else (or use constructor).

as @alexeyromanov suggested, can implement specific monads (e.g. make option interface), abstract concept of monad not possible in java. of course means cannot create useful functions work monad.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -