Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | generics@haskell.org |
Summary: Generic function that applies a (non-generic) function to every element in a value, splitting the element into two. The result is a pair of structurally equivalent values, one with the elements from the first component of the splitting function and the other with the elements from the second component.
UnzipWith
can be seen as the dual of ZipWith
, though it has no direct
Prelude
counterpart. Only unzip
has a Prelude
analog.
See also Generics.EMGM.Functions.ZipWith.
Documentation
newtype UnzipWith m a b c Source
The type of a generic function that takes an argument of one type and returns a pair of values with two different types.
UnzipWith | |
|
:: (Monad m, FRep3 (UnzipWith m) f) | |
=> (a -> m (b, c)) | Splitting function. |
-> f a | Container of |
-> m (f b, f c) | Pair of containers. |
Splits a container into two structurally equivalent containers by applying a function to every element, which splits it into two corresponding elements. Fails if the spliting function fails
unzipWith :: FRep3 (UnzipWith Id) f => (a -> (b, c)) -> f a -> (f b, f c)Source
A specialized version of unzipWithM
using the identity monad and a
splitting function that does not fail.