News for hackers. Stuff that matters.
Re:Announcing TypeScript 1.6 by matchu on Wednesday September 16, 2015 @05:56PM (#10230167)
I don't know much about type theory, so I suspect that my intuition is wrong, but the phrase "intersection type" violates my intuition.

If I have Printable and Drawable interfaces, which each describe a set of behaviors, then I would expect the "intersection" of Printable and Drawable to be the intersection of those sets of behaviors — which, here, is likely the empty set.

Is there another way of understanding types that makes the word "intersection" make more sense here? Or is it just to say that "where union types say OR, intersection types say AND"?

---

...ya know what? By typing it out, I think I get it now.

The set that we're talking about isn't the set of Printable's behaviors; it's the set of things that implement Printable. `Printable & Drawable` is the intersection of the set of types that implement Printable with the set of types that implement Drawable. Got it. Thanks for rubber-ducking for me, HN!

Re:Announcing TypeScript 1.6 by spicyj on Wednesday September 16, 2015 @05:59PM (#10230181)
Objects whose type is a subtype of "Printable | Drawable" (union) are those that implement either interface. For "Printable & Drawable" (intersection), you have objects that implement both interfaces. Meaning, those objects that have both .print() and .draw() (or similar).

You're not taking the intersection of the interfaces, but of the sets of objects that implement them.

Re:Announcing TypeScript 1.6 by CurtHagenlocher on Wednesday September 16, 2015 @05:59PM (#10230184)
I found some of the comments at http://stackoverflow.com/questions/5653678/union-types-and-i... helpful. If TAPL refers to "intersection types" then it's definitely a well-defined concept.
Re:Announcing TypeScript 1.6 by zeckalpha on Thursday September 17, 2015 @11:18PM (#10237327)
There's also sum and product types, again by analogy.
Re:Announcing TypeScript 1.6 by ken47 on Wednesday September 16, 2015 @05:59PM (#10230185)
It's not the same sort of intersection as you might understand it from mathematical sets: http://stackoverflow.com/questions/5653678/union-types-and-i...

See the response about C#.

Re:Announcing TypeScript 1.6 by WorldMaker on Thursday September 17, 2015 @09:39AM (#10233247)
It is referring to mathematical sets, but at the categorization of types level rather than the "shape" of types.

If you think of Set X consisting of all the objects that could possibly be built as Class X and Set Y as all the objects that could possibly be built as Class Y, then the union of those sets is all of the Class X derived objects and all of the Class Y derived objects, whereas the intersection of those sets are whatever objects manage to implement or derive from both Class X and Class Y.