[Haskell-cafe] RE: "first class" tuples?
Brian Bloniarz
phunge0 at hotmail.com
Fri Feb 20 23:36:20 EST 2009
Wolfgang Jeltsch wrote:
> Make , an infix operator. Then even the syntax (,) works without further ado.
> Make , right-associative, for example. Then you can write (a1,...,an) which
> means (a1,(a2,(...,an))). You just need one data declaration:
>
> data (a,b) = (a,b)
>
> However, this has the problem that it leads to more partially-defined values
> than with today's tuples. For example, you could have a *triple* (a,_|_).
>
> So maybe we should treat tuple syntax completely as special syntax (as it is
> today) and define our tuple types so that tuples don't end with the last
> element (as above) but with an explicit empty tuple (like lists end in a
> nil). This would also give use 1-tuples. We would need the unit type () for
> empty tuples. Then we define a cons type which has a strictness annotation:
>
> data head :# tail = head :# !tail
Lennart Augustsson wrote:
> Look at the HList stuff by Oleg and others and you'll find the kind of
> tuples you suggest.
One thing about HList: the HCons type is lazy in its second element,
so HList tuples can be more partially-defined than normal tuples.
Anybody know the rationale for this? I'm curious whether it could
be changed, or if any code depends on it.
-Brian
_________________________________________________________________
Access your email online and on the go with Windows Live Hotmail.
http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_HM_AE_Access_022009
More information about the Haskell-Cafe
mailing list