I needed a monadic version of
partition today. I settled on the following version:
partitionM :: Monad m => (a -> m Bool) -> [a] -> m ([a], [a]) partitionM p xs = bimap (map fst) (map fst) . partition snd . zip xs <$> mapM p xs
Then I realized it's already implemented here:
partitionM :: Monad m => (a -> m Bool) -> [a] -> m ([a], [a]) partitionM f  = return (, ) partitionM f (x:xs) = do res <- f x (as,bs) <- partitionM f xs return ([x | res]++as, [x | not res]++bs)
This second version doesn't have to pull in extra packages and doesn't create intermediate lists, but mine is shorter and doesn't have explicit recursion. What do you think of my solution in comparison with the library's implementation?