module Control.Monad.Ext ( zipWithM , zipWithM_ ) where import Data.Foldable (sequenceA_) import Data.List.NonEmpty import qualified Data.List.NonEmpty as NE zipWithM :: (Applicative m) => (a -> b -> m c) -> NonEmpty a -> NonEmpty b -> m (NonEmpty c) zipWithM :: forall (m :: * -> *) a b c. Applicative m => (a -> b -> m c) -> NonEmpty a -> NonEmpty b -> m (NonEmpty c) zipWithM a -> b -> m c f NonEmpty a xs NonEmpty b ys = forall (t :: * -> *) (f :: * -> *) a. (Traversable t, Applicative f) => t (f a) -> f (t a) sequenceA (forall a b c. (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c NE.zipWith a -> b -> m c f NonEmpty a xs NonEmpty b ys) zipWithM_ :: (Applicative m) => (a -> b -> m c) -> NonEmpty a -> NonEmpty b -> m () zipWithM_ :: forall (m :: * -> *) a b c. Applicative m => (a -> b -> m c) -> NonEmpty a -> NonEmpty b -> m () zipWithM_ a -> b -> m c f NonEmpty a xs NonEmpty b ys = forall (t :: * -> *) (f :: * -> *) a. (Foldable t, Applicative f) => t (f a) -> f () sequenceA_ (forall a b c. (a -> b -> c) -> NonEmpty a -> NonEmpty b -> NonEmpty c NE.zipWith a -> b -> m c f NonEmpty a xs NonEmpty b ys)