:: [[a]] -> [[a]]

The transpose function transposes the rows and columns of its argument.

Laziness

transpose is lazy in its elements
>>> take 1 (transpose ['a' : undefined, 'b' : undefined])
["ab"]

Examples

>>> transpose [[1,2,3],[4,5,6]]
[[1,4],[2,5],[3,6]]
If some of the rows are shorter than the following rows, their elements are skipped:
>>> transpose [[10,11],[20],[],[30,31,32]]
[[10,20,30],[11,31],[32]]
For this reason the outer list must be finite; otherwise transpose hangs:
>>> transpose (repeat [])
* Hangs forever *
Transform
[[00,01,02,...],          [[00],
[10,11,12,...],   -->     [10,01],
[20,21,22,...],           [20,11,02],
...]                      ...]
With concat . shear you can perform a Cantor diagonalization, that is an enumeration of all elements of the sub-lists where each element is reachable within a finite number of steps. It is also useful for polynomial multiplication (convolution).
Transform
[[00,01,02,...],          [[00],
[10,11,12,...],   -->     [01,10],
[20,21,22,...],           [02,11,20],
...]                      ...]
It's like shear but the order of elements in the sub list is reversed. Its implementation seems to be more efficient than that of shear. If the order does not matter, better choose shearTranspose.
\xs -> shearTranspose xs  ==  map reverse (shear (xs::[String]))
The transpose function transposes the rows and columns of its argument. For example,
>>> transpose [[1,2,3],[4,5,6]]
[[1,4],[2,5],[3,6]]
If some of the rows are shorter than the following rows, their elements are skipped:
>>> transpose [[10,11],[20],[],[30,31,32]]
[[10,20,30],[11,31],[32]]
For this reason the outer list must be finite; otherwise transpose hangs:
>>> transpose (repeat [])
* Hangs forever *
transpose is lazy:
>>> take 1 (transpose ['a' : undefined, 'b' : undefined])
["ab"]
The transpose function transposes the rows and columns of its argument. For example,
>>> transpose [[1,2,3],[4,5,6]]
[[1,4],[2,5],[3,6]]
If some of the rows are shorter than the following rows, their elements are skipped:
>>> transpose [[10,11],[20],[],[30,31,32]]
[[10,20,30],[11,31],[32]]
The transpose function transposes the rows and columns of its argument. For example,
>>> transpose [[1,2,3],[4,5,6]]
[[1,4],[2,5],[3,6]]
If some of the rows are shorter than the following rows, their elements are skipped:
>>> transpose [[10,11],[20],[],[30,31,32]]
[[10,20,30],[11,31],[32]]
For this reason the outer list must be finite; otherwise transpose hangs:
>>> transpose (repeat [])
* Hangs forever *
Like diagonal, but expose a tiny bit more (non-semantic) information: if you lay out the input list in two dimensions, each list in the result will be one of the diagonals of the input. In particular, each element of the output will be a list whose elements are each from a distinct input list.
Slightly unfair n-way Cartesian product: given a finite number of (possibly infinite) lists, produce a single list such that whenever vi has finite index in list i for each i, [v1, ..., vn] has finite index in the output list.
Very unfair n-way Cartesian product: same guarantee as the slightly unfair one, but not as good in the same sense that the very unfair 2-way product is worse than the slightly unfair 2-way product.
Delays the enumeration of tiers. Conceptually this function adds to the weight of a constructor.
delay [xs, ys, zs, ... ]  =  [[], xs, ys, zs, ...]
delay [[x,...], [y,...], ...]  =  [[], [x,...], [y,...], ...]
Typically used when defining Listable instances:
instance Listable <Type> where
tiers  =  ...
\/ delay (cons<N> <Constructor>)
\/ ...
Resets any delays in a list-of tiers. Conceptually this function makes a constructor "weightless", assuring the first tier is non-empty.
reset [[], [], ..., xs, ys, zs, ...]  =  [xs, ys, zs, ...]
reset [[], xs, ys, zs, ...]  =  [xs, ys, zs, ...]
reset [[], [], ..., [x], [y], [z], ...]  =  [[x], [y], [z], ...]
Typically used when defining Listable instances:
instance Listable <Type> where
tiers  =  ...
\/ reset (cons<N> <Constructor>)
\/ ...
Be careful: do not apply reset to recursive data structure constructors. In general this will make the list of size 0 infinite, breaking the tiers invariant (each tier must be finite).
Normalizes tiers by removing up to 12 empty tiers from the end of a list of tiers.
normalizeT [xs0,xs1,...,xsN,[]]     =  [xs0,xs1,...,xsN]
normalizeT [xs0,xs1,...,xsN,[],[]]  =  [xs0,xs1,...,xsN]
The arbitrary limit of 12 tiers is necessary as this function would loop if there is an infinite trail of empty tiers.
Evaluate each action in the sequence from left to right, and collect the results.
This function is only used in Quote when desugaring brackets. This is not necessary for the user, who can use the ordinary return and (>>=) operations.
This is a version of sequence based on difference lists. It is slightly faster but we mostly use it because it uses the heap instead of the stack. This has the advantage that Neil Mitchell’s trick of limiting the stack size to discover space leaks doesn’t show this as a false positive.
Evaluate each action in the structure from left to right, and collect the results. For a version that ignores the results see sequenceA_.

Examples

Basic usage: For the first two examples we show sequenceA fully evaluating a a structure and collecting the results.
>>> sequenceA [Just 1, Just 2, Just 3]
Just [1,2,3]
>>> sequenceA [Right 1, Right 2, Right 3]
Right [1,2,3]
The next two example show Nothing and Just will short circuit the resulting structure if present in the input. For more context, check the Traversable instances for Either and Maybe.
>>> sequenceA [Just 1, Just 2, Just 3, Nothing]
Nothing
>>> sequenceA [Right 1, Right 2, Right 3, Left 4]
Left 4