Expression
Expression copied to clipboard
Generic monad algorithm
Is it possible to define a function that can handle multiple types of effects depends on the object that yields the effect? Like in Haskell
join :: Monad m => m (m a) -> m a
join xss =
do xs <- xss
xs
which would work for all monads including, list, maybe, io, stm, etc...
I can help about it if needed.
No, I don't think it's possible e.g an iterable join is very different from an observable join so each world will need a specific implementation. It will not be possible for the specific implementation to be registered as an auto-dispatch / overload. But if you have a suggestion then please feel free to explain what idea you have in mind.