[Haskell-cafe] "first class" tuples?

Peter Verswyvelen bugfact at gmail.com
Tue Feb 17 08:42:48 EST 2009


Tuples in Haskell always have annoyed me a bit since each tuple of different
dimension is hardcoded (I guess compilers enforce a maximum dimension on
tuples?)
Since a tuple represents a fixed size data structure with different types at
each coordinate, it feels as it should be possible to have a couple of type
and data constructors to build a tuple, and to use recursion at the type
level to have functions operate on tuples of any dimension.

E.g. one could then have a tmap function that takes a tuple of functions and
a tuple of values and applies the function at coordinate N to the value at
coordinate N.

Is something like this possible today in Haskell, e.g. using new features
like type families, GADTs, template haskell, etc? Or do we need dependent
types for it?

In C++x0 I believe it is now possible to do so, since they even allow a
variable number of template arguments, using recursion at compile time (see
e.g.
http://publib.boulder.ibm.com/infocenter/comphelp/v9v111/index.jsp?topic=/com.ibm.xlcpp9.aix.doc/standlib/header_tuple.htm
 )

Grapefruit has something like first class records, so I guess it should be
possible (and simpler) to do this for tuples?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090217/9cadca22/attachment.htm


More information about the Haskell-Cafe mailing list