| Portability | non-portable (MPTCs, FunDeps,...) |
|---|---|
| Stability | experimental |
| Maintainer | wren@community.haskell.org |
Data.List.ZipWithN
Description
Provides a polyvariadic 'map'/'zipWith' like the map in Scheme.
For more details on this style of type hackery, see:
- Chung-chieh Shan, A polyvariadic function of a non-regular type (Int->)^N ([]^N e)->... http://okmij.org/ftp/Haskell/polyvariadic.html#polyvartype-fn
For alternative approaches to solving this problem, see also
- http:paczesiowa.blogspot.com201003/generalized-zipwithn.html
- http:hackage.haskell.orgpackagesarchiveTypeComposelatestdochtml/Data-Zip.html
Documentation
class ZipWithN a gr kr | kr -> gr aSource
This class provides the necessary polymorphism. It is only exported for the sake of giving type signatures.
Because we can't do functor composition without a lot of noise
from newtype wrappers, we use gr and kr to precompose the
direct/list functor with the reader functor and the return type.
zipWithN :: ZipWithN a gr kr => (a -> gr) -> [a] -> krSource
Polyadic version of 'map'/'zipWith'. The given type signature isn't terribly helpful or intuitive. The real type signature is:
zipWithN :: {forall a}^N. ({a->}^N r) -> ({[a]->}^N r)
Note that the a type variables are meta and so are independent
from one another, despite being correlated in N across all
repetitions.