[Haskell-cafe] Showing the 1 element tuple

Neil Mitchell ndmitchell at gmail.com
Tue Dec 19 19:32:06 EST 2006


Hi

> Python uses the syntax (foo,) to denote a singleton tuple (that is an extra
> comma at the end); quoting the python tutorial "Ugly, but effective".

Yes, I thought of that, the issue is:

(a,b) is considered syntactic sugar for (,) a b
(a,) is syntactic sugar for...

And the place I'm displaying this is definately after desugaring!

> Could tuples be implemented as an HList?
> singleton = (`hCons` hNil)

Not in Yhc, no higher rank types :) Also tuples are really really
common, every class function has quite a few floating around - HList
is just too much overhead (I think).

> Tuples represent dimensionality therefore a 1-element tuple is just a
> 1-dimensional value ie the value itself hence a == (a) == ((a)) == (((a)))

Tuples are a box you can put things in, in Haskell:

data Tuple a = Tuple a

Tuple (Tuple 1) /= 1

(either at runtime, at type time, or any other time)

Thanks

Neil


More information about the Haskell-Cafe mailing list