Expression icon indicating copy to clipboard operation
Expression copied to clipboard

Generic monad algorithm

Open denghz opened this issue 3 years ago • 1 comments

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.

denghz avatar Oct 18 '22 06:10 denghz

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.

dbrattli avatar Oct 18 '22 14:10 dbrattli