Or could we define a category where zero and one were separate objects?

]]>it should be

interface Category {

interface Object {}

interface Morphism {}

class IllegalCompositionError extends Error {}

Object source(Morphism m);

Object target(Morphism m);

Morphism identity(Object o);

Morphism compose(Morphism m1, Morphism m2) throws IllegalCompositionError;

};

> and 2^31 – 1, as opposed to Long?

:) Probably! Unfortunately, WordPress’ editor isn’t idempotent; I think it doesn’t support the <pre> tag properly. So I had to compose this in a text editor and then paste it in. Unfortunately, I deleted the file, so it’s hard to make corrections.

]]>> “object” in Java is the values which are members of the classes.

Only sometimes. Reread the first paragraph in section 1: the collection of objects is the set of values associated to a class, just as you said. In the “Category” interface, the objects are the members of the internal interface “Object.”

In Java, there’s a class “Class” whose objects are classes. So I can say internal interfaces are objects, since they’re instances of Class. This is closer to the way category theory is used, since we often want the objects of our categories to be collections themselves.

]]>Essentially, only one set of elements.

Remember, a monoid is usually defined to be a set M with an associative multiplication table and a unit element, satisfying the left- and right-unit equations. For every element x of M there’s a corresponding function

f_x(Z) = x * Z

that multiplies on the left by x. Then composition is “the same as” multiplication:

f_x( f_y( Z ) ) = x * y * Z = f_{x*y}(Z)

More concisely,

f_x o f_y = f_{x*y}

where o means compose.

Since composition is a built-in operation on morphisms in category theory, we can take M as our one object and let

hom(M, M) = {f_x: M->M such that x is an element of M}.

]]>http://programming.reddit.com/info/5zshz/comments/

One common sentiment was, “Why do I need category theory to be a programmer?” You don’t, of course: my intended audience is the programmer who’s heard about category theory and wants an accessible introduction.

Another was the question “why a whole set of morphisms between two objects? Shouldn’t there just be one, where f(a) = b?” It was suggested that in Haskell, Int is an object; the same is true in Java. It’s not widely known among any but the most advanced Java programmers, but all Java classes are instances of the class “Class.”

]]>Mike Stay has just posted “Category Theory for the Java Programmer,” an introduction to the subject intended for people with practical programming experience. This is the latest, but hopefully not the last, in a series of introductory arti…

]]>