I am attempting to filter a list of type:
IO [Either a b]
Ideally, I would like to compose filtering function with the following type sig:
(Monad m, Monad m2) => m [m2 a] -> (a -> Bool) -> m [m2 a]
I have tried a lot of combinations of
=<< in a vain attempt to lift my predicate into the proper context, but I keep missing the mark - I can achieve
m [m a]-> (a -> m Bool)-> m [m a], but since Either and IO are not the same monad, this doesn't seem to do me any good.
This seems like a usecase for 'do notation' , but I've been unable to suss out a way to examine the type signatures of things assigned with the
<- operator, and so am left shooting at a moving target.
I am not sure how to compose the function in a way that will make it clear that it's traversing a list containing a instances of a different monad (Either) then the monad that contains the list itself (IO).
What am I missing here?