I have a beginner question concerning monads. How would you call a concept where monads
are nested but are used in a transparent way by users?
Assume you have a monad M[A]. Then the method 'bind' uses the type A and
produces another type M[B]. When I now have another monad G which wraps
the first one, I now have a G[M[A]]. Now G's bind method refers not to A
but to M[A]. So in case when you have several levels of nesting, for the
user it gets complicated (e.g. I[H[G[M[A]]]]) of using a bind method,
because they also have to be called in a nested way.
Is there already a concept saying that when having nested monads, there
is some kind of special bind method that only refers to the inner monad?
In my case I want to work with collections and wrap it by one or more
val b: M[List[A]] = ....
in class M:
def map(f: A => B): M[List[B]] = .....
or val g: G[M[A]] = .....
in class G
def map(f: A => B): G[M[B]]
These monads add side-effects (e.g. automatically filter the result
sets; without changing the result type) and should be transparent which
means the user should work with it as if it is only a collection (of
course the collection's interface is overlapped by the one of the monad).
Is there already a concept for that defined and available?