You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I find this function handy sometimes. A zipWithM for lists of equal length.
zipWithM' :: (MonadPlus m, Functor m) => (a -> b -> m c) -> [a] -> [b] -> m [c]
zipWithM' _ [] [] = return []
zipWithM' f (x:xs) (y:ys) = (:) `fmap` f x y `ap` zipWithM' xs ys
zipWithM' _ _ _ = mzero
And of course it's counterpart zipWithM'_ :: MonadPlus m => (a -> b -> m c) -> [a] -> [b] -> m ().
The text was updated successfully, but these errors were encountered:
This seems very special-purpose. I'm not sure it makes sense to include here, at least not without a more descriptive name. People who don't realize there's already a zipWithM in Control.Monad would likely assume a function with this name to be the same, and the use of the "prime" doesn't really match that of other functions in this package or the more widely known convention (that it indicates a stricter version of the same function).
I'm not totally against it, but I think I need a fairly compelling argument or a more descriptive name before I'll be convinced it fits.
Well I don't see how this is "very special-purpose" I've found use cases for it in real code I've implemented while I never actually needed to use zipWithM from Control.Monad in real code.
I actually suggested the name zipWithM' since it goes well with the naming conventions of the packages itself mentioned here. "Functions with names ending in ' collect their results into MonadPlus containers."
I don't care at all about the name though. If you find a more appropriate name please use it.
Hi,
I find this function handy sometimes. A zipWithM for lists of equal length.
And of course it's counterpart
zipWithM'_ :: MonadPlus m => (a -> b -> m c) -> [a] -> [b] -> m ()
.The text was updated successfully, but these errors were encountered: