News for hackers. Stuff that matters.
Re:Translating Mathematics into Code: Examples in Java, Pyth... by Klockan on Tuesday February 10, 2015 @04:01AM (#9026057)
Union types is not a key concept in abstract algebra, I bet that most mathematicians have never even heard of it. I'd like to hear about its use in abstract algebra, how would you define the union type of the simplest of simple objects without breaking its operation: a group with a group?
Re:Translating Mathematics into Code: Examples in Java, Pyth... by j2kun on Tuesday February 10, 2015 @10:48AM (#9027815)
The concept is called a coproduct. The coproduct of two sets is the disjoint union. The coproduct of two abelian groups is also called the direct sum [edited], and the category of general groups does not have coproducts. The coproduct of two types in the category of types is exactly the union type. The idea of an Abelian category (basically, a "nice" category) requires the existence of coproducts, which I think is widely used enough in universal algebra to be considered a key concept.

I wrote a long (and unfinished) series about how to interpret category theory with programs on my blog [0], and in [1] I cover universal properties and the coproduct, which describes how you would formulate a "union type" in any category.

[0]: http://jeremykun.com/ [1]: http://jeremykun.com/2013/05/24/universal-properties/

Re:Translating Mathematics into Code: Examples in Java, Pyth... by kyllo on Tuesday February 10, 2015 @10:41AM (#9027757)
I didn't say that union types are a key concept in abstract algebra, and I'm not a mathematician by any means, although I vaguely understand that a disjoint union is a thing in set theory.

What I'm saying is that languages that do embrace concepts from abstract algebra, are much more expressive than languages that eschew these concepts (like Java).

Re:Translating Mathematics into Code: Examples in Java, Pyth... by throwaway283719 on Tuesday February 10, 2015 @05:41AM (#9026381)
That would be a groupoid - http://en.wikipedia.org/wiki/Groupoid
Re:Translating Mathematics into Code: Examples in Java, Pyth... by Klockan on Tuesday February 10, 2015 @06:52AM (#9026596)
No, groupoids breaks the group operation and thus behaves like neither of the groups. Do type systems allow operations between union types? If not then it is just a simple interface in OO. If they do then you are no longer working with pure functions.