
Polyvariadic functions that accept an indefinite number of possibly multiple typed arguments are often useful but a bit difficult to declare in Haskell. With some crucial assistance from Oleg Kiselyov, I have created a library that supplies two very general polyvariadic functions that can map their arguments into any monoid you specify. All you need to do to use these is to specify the monoid and some instances of a toMonoid function to map all the types you want to pass as arguments into the monoid. The functions can act as a sort of generalised list, but of course there are also many interesting monoids which are not lists. The library is now up on Hackage here: http://hackage.haskell.org/package/polyToMonoid-0.1 along with detailed documentation and a few examples here: http://hackage.haskell.org/packages/archive/polyToMonoid/0.1/doc/html/Data-P... As you can see, the code is short and depends only upon the GHC base library. The original thread discussing the polyToMonoid idea is here: http://groups.google.com/group/haskell-cafe/browse_thread/thread/737c6cf921b... Comments and suggestions for improvement are welcome! Kevin
participants (1)
-
Kevin Jardine