I've written two monads m1
and m2
whose semantics are such that it's possible to define this operation:
bindM1AndM2: (a -> m1 (m2 b)) -> m1 (m2 a) -> m1 (m2 b)
This is like >>=
, but for binding double monads with an a
inside an m2
inside an m1
, and using that to convert the inner type while preserving the two outer monad layers.
Is there a general name for this operation in Haskell? Are there certain general type class(es) for which it makes sense, and can it be built from more fundamental building blocks? I'm familiar with the one particular example I'm working on, but not sure if there is something deeper here.