If you define f2 , refactoring f2 can be the easiest way, so it will be defined as follows:
f2 :: Monad m => WriterT [String] mb
This should not be too complicated, because Writer wb is defined as WriterT w Identity b , and the Identity monad does nothing.
Then you can connect them by doing f1 >> f2 .
If you cannot override f2 , you can always define your own with the appropriate signature:
f2' :: Monad m => WriterT [String] mb f2' = WriterT . return $ runWriter f2
And if you have a bunch of f2 for wrapping, you can always define a function to wrap them for you
wrap :: Monad m => Writer wb -> WriterT wmb wrap = WriterT . return . runWriter
So you can do f1 >> wrap f2a >> wrap f2b >> wrap f2c ...
rampion
source share