Fwd: [Haskell-cafe] Is () a 0-length tuple?

The syntax is similar, but what else is?
In JavaScript there is a "null" value, that is the only value of the null type.
Isn't () the same thing? The only value of the unary type?
Best,
titto
2009/11/6 John Dorsey
In what sense () is a 0-length tuple?
In what sense isn't it?
Data.Tuple is much to narrow to be of any use here. () is in at least most, if not all, of the type classes that tuples are in. The syntax is strikingly similar.
If you ask me, it walks/quacks/smells like a duck, so it's a duck.
Regards, John
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Pasqualino "Titto" Assini, Ph.D. http://quicquid.org/

2009/11/7 Pasqualino "Titto" Assini
The syntax is similar, but what else is?
In JavaScript there is a "null" value, that is the only value of the null type.
Isn't () the same thing? The only value of the unary type?
No, () has two values: () and undefined (t.i., _|_).
Best,
titto
2009/11/6 John Dorsey
: In what sense () is a 0-length tuple?
In what sense isn't it?
Data.Tuple is much to narrow to be of any use here. () is in at least most, if not all, of the type classes that tuples are in. The syntax is strikingly similar.
If you ask me, it walks/quacks/smells like a duck, so it's a duck.
Regards, John
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Pasqualino "Titto" Assini, Ph.D. http://quicquid.org/ _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Eugene Kirpichov Web IR developer, market.yandex.ru

Eugene Kirpichov
In JavaScript there is a "null" value, that is the only value of the null type. Isn't () the same thing? The only value of the unary type?
No, () has two values: () and undefined (t.i., _|_).
I'd argue that yes, they're the same thing, since any function returning "null" in JS might also fail to terminate or terminate with an exception. -k -- If I haven't seen further, it is by standing in the footprints of giants

On Sun, Nov 8, 2009 at 9:52 AM, Ketil Malde
Eugene Kirpichov
writes: In JavaScript there is a "null" value, that is the only value of the null type. Isn't () the same thing? The only value of the unary type?
No, () has two values: () and undefined (t.i., _|_).
How should I put it..? undefined is bottom, but bottom is not undefined? There are plenty of other constructions that are bottom. Infinite loops, throws, errors.. common for all of them, of course, is that you can't pattern-match on them or otherwise use them in pure code, and they generally don't act like values. So, can't we just say that () has a single value, namely ()? It'd make this much simpler, and we won't have to deal with the Nihil monoid. == data Nihil instance Monoid Nihil where mappend _ _ = undefined -- Svein Ove Aas

How about this? {-# LANGUAGE ThinkTotal #-} On 8 Nov 2009, at 09:53, Svein Ove Aas wrote:
On Sun, Nov 8, 2009 at 9:52 AM, Ketil Malde
wrote: Eugene Kirpichov
writes: In JavaScript there is a "null" value, that is the only value of the null type. Isn't () the same thing? The only value of the unary type?
No, () has two values: () and undefined (t.i., _|_).
() is the only value of (). If we could agree a standard set of email pragmas, we could save ourselves a lot of violent agreement. Cheers Conor

"Pasqualino \"Titto\" Assini"
The syntax is similar, but what else is?
What would you expect from an empty tuple? (a,b,c) has a constructor function p3 a b c = (a,b,c) and three destructor functions s3_1 (a,b,c) = a, s3_2 (a,b,c) = b and s3_3 (a,b,c)=c (a,b) has a constructor function p2 a b = (a,b) and two destructor functions s2_1 (a,b) = a and s2_2 (a,b) = b (a) has a constructor function p1 a = (a) and one destructor function s1_1 a = a () has a constructor function p0 = () and zero destructor functions.
In JavaScript there is a "null" value, that is the only value of the null type.
I'm not sure that Javascript is a suitable place to get intuitions for Haskell (null type would seem more like empty than single), but anyway, the thing is that the sole (non-bottom) value of the /unit/ type is the same as the empty tuple¹.
Isn't () the same thing? The only value of the unary type?
The "empty" type in Haskell would be (forall a.a) which has no non-bottom values. [1] Aside: I wanted haskell to share the same type for all empty values (ie lists would have been symmetric unions of pairs with the unit type List t = (t,List t) || ()), but that didn't fit with algebraic datatypes so the design went a different way. -- Jón Fairbairn Jon.Fairbairn@cl.cam.ac.uk

Jon Fairbairn
The "empty" type in Haskell would be (forall a.a) which has no non-bottom values.
With an extension, you can also define: data Void -- without any constructors which is perhaps closer to null types in other languages? -k -- If I haven't seen further, it is by standing in the footprints of giants
participants (6)
-
Conor McBride
-
Eugene Kirpichov
-
Jon Fairbairn
-
Ketil Malde
-
Pasqualino "Titto" Assini
-
Svein Ove Aas