Wed, 9 Aug 2000 20:27:14 +0100, Claus Reinke <[EMAIL PROTECTED]> pisze:

> In the language I had in mind, I would expect to be able to "retrieve" the
> () from any product, at any position

I still prefer the list-like non-associative treatment of tuples.
It needs not type system extensions.

The only problem is that GHC and other compilers are not able to
represent such tuples compactly. Theoretically they could just do
it, these nested pairs are isomorphic to real tuples, but GHC never
unboxes polymorphic fields, for obvious reasons. It would require
either physical specialization of code for each length or ability
to extract and make variable-sized fields.

Specialization is better, the latter would have quadratic cost for
large tuples. But it's not possible in polymorphic recursion and I
can hardly imagine multiple representations of a single type.


data Pair h t = h :* !t

class ConcTuples a b c where
    concTuples :: a -> b -> c
instance ConcTuples () b b where
    concTuples _ b = b
instance ConcTuples b c d => ConcTuples (Pair a b) c (Pair a d) where
    concTuples (a:*b) c = a :* concTuples b c


Note that () as a strict constructor argument does not need any
physical representation.

-- 
 __("<  Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK


Reply via email to