Tuple-like constructors
Malcolm Wallace
Malcolm.Wallace at cs.york.ac.uk
Tue Feb 7 09:49:17 EST 2006
Robert Dockins <robdockins at fastmail.fm> writes:
> > i would argue against treating tuples as pure syntactic sugar for
> > nested pairs; since the nesting carries hierarchical information, i
> > would expect (x,y,z) used in place of (x,(y,z)) to cause an error.
Indeed, quite apart from anything else, transforming tuples into
nested tuples changes the performance of access from constant-time
into linear-time (using the right-nested transformation specified
by Robert), or at best, log-time (using a balanced tree schema).
This is highly undesirable.
> The copout (in my opinion) is the current system where tuples are
> defined up to some set n (64 in GHC I think -- the report only
> mandates 15), and if you want bigger tuples you're SOL.
To address this problem, I think we should permit user-definition of
tuple constructors with the expected syntax e.g. (,,,,,), which is
already accepted by at least some compilers (nhc98,yhc).
> More disturbing is the complete inability to write general functions
> over tuples.
> The only fully general solution is to use something
> like template haskell which 1) is overkill 2) has ugly syntax (sorry
> but it's true) 3) GHC only and 4) hard to learn.
I don't believe you need to invoke the full awesome majesty of
Template Haskell in this case. Surely plain -fgenerics will suffice?
I am hoping that some simple form of data-type generics will make it
into the new standard.
Regards,
Malcolm
More information about the Haskell-prime
mailing list