The short answer is no. notation is based on two things
return :: a -> ma >>= :: ma -> (a -> mb) -> mb
Note >>= that although you can work with two different internal types ( a and b ), it only works with one external type, one monad ( m ). Both ma and a -> mb are the same monad.
The longer the answer, you have to convert them to one monad. For example, Maybe can be converted to IO as follows:
maybeToIO Nothing = error "No thing" maybeToIO (Just a) = return a
Monads, generally speaking, cannot be transformed into each other, although, with the exception of special cases.
So why >>= only works with one monad? Well, just look at this . It is defined to work with one monad at a time, and the definition-designation is defined for working with >>= . The reasons for choosing this definition are somewhat complicated, but I can edit it if someone wants to.
You can create your own >>= , which will work with several monads, and then use the repeating syntax , but this will probably be difficult.
Pyulez
source share