Summary: Generic function that applies a (non-generic) function to every pair of corresponding elements in two structurally equivalent polymorphic values to produce a third (also structurally equivalent) value with the result of each application in every element location.
The important concepts for
zipWithM are structural equivalence and
corresponding elements. For
zipWithM to be successful (and not
its two container arguments must have exactly the same shape. If the shapes
of the arguments differ, then it is unclear what the shape of the result is
supposed to be. As a result,
Corresponding elements are those elements that are located in the same place in the tree of each argument. If you were to traverse the tree to get to element x in one tree, then its corresponding element y in the other tree should require the exact same path to reach it.
See also Generics.EMGM.Functions.UnzipWith.
The type of a generic function that takes two arguments of two different types and returns a value of a third type in a Monad.
|:: (Monad m, FRep3 (ZipWith m) f)|
|=> (a -> b -> m c)|
Binary operator on elements of containers.
|-> f a|
|-> f b|
|-> m (f c)|
Combine two structurally equivalent containers into one by applying a
function to every corresponding pair of elements. Fails if (1) the binary
operator fails or (2)
f a and
f b have different shapes.