emgm-0.4: Extensible and Modular Generics for the Masses

Portabilitynon-portable
Stabilityexperimental
Maintainergenerics@haskell.org

Generics.EMGM.Functions.UnzipWith

Description

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.

Synopsis

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.

Constructors

UnzipWith 

Fields

selUnzipWith :: a -> m (b, c)
 

Instances

unzipWithMSource

Arguments

:: (Monad m, FRep3 (UnzipWith m) f) 
=> (a -> m (b, c))

Splitting function.

-> f a

Container of a-values.

-> 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.

unzip :: FRep3 (UnzipWith Id) f => f (b, c) -> (f b, f c)Source

A specialized version of unzipWith for pairs. Generic version of Prelude.unzip.