Generalize mapMaybe to mapFoldable