[Python-Dev] type categories

Andrew Koenig ark@research.att.com
Mon, 26 Aug 2002 15:10:59 -0400 (EDT)

Oren> On Mon, Aug 26, 2002 at 11:57:31AM -0400, Andrew Koenig wrote:
>> Incidentally, it just occurred to me that if we regard categories
>> as claims about types (or, if you like, predicate functions with type
>> arguments), then it makes sense to include (Cartesian) product types.

Oren> Would such as product type be anything more than than a
Oren> predicate about tuples?

No, I don't think it would.

Indeed, ML completely unifies Cartesian product types and tuples in a
very, very cool way:

      Every function takes exactly one argument
      and yields exactly one result.

      However, the argument or result can be a tuple.

So in ML, when I write


that really means to bundle x and y into a tuple, and call f with that
tuple as its argument.  So, for example, if I write

      val xy = (x,y)

which defines a variable named xy and binds it to the tuple (x,y), then

      f xy

means exactly the same thing as


The parentheses are really tuple constructors, and ML doesn't require
parentheses for function calls at all.

However, if you're going to define predicates over tuples of (Python)
types, then you had better not try to define those predicates as part
of the tuples' class definitions, because they don't have one.