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
Post a Comment