wren-extras-2011.7.13: wren ng thornton's random collection of extras

Portabilitynon-portable (MPTCs, FunDeps,...)
Stabilityexperimental
Maintainerwren@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:

For alternative approaches to solving this problem, see also

  • http:paczesiowa.blogspot.com201003/generalized-zipwithn.html
  • http:hackage.haskell.orgpackagesarchiveTypeComposelatestdochtml/Data-Zip.html

Synopsis

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.

Instances

ZipWithN a b [b] 
ZipWithN b gr kr => ZipWithN a (b -> gr) ([b] -> kr) 

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.