Guido van Rossum wrote:
... https://chadaustin.me/2015/07/sum-types/ ... unions in Python are always tagged (since you can alway introspect the object type).
Greg Ewing replied:
The "Sum" types talked about in the referenced article are what Haskell calls "algebraic types". They're not really the same as the Union[X,Y] types we're talking about here, because a Union type simply tells the type checker that one of a number of different types could be present at run time. The code might introspect on the type, but it doesn't have to do anything special to access one of the branches of the union -- it just goes ahead and uses the value.
An algebraic type, on the other hand, is a new type of run-time object that has to be explicitly unpacked to access its contents. It's more like a class in that respect.
I know. But this could be considered syntactic sugar. And the article insists that Sum types are not really the same as classes either (they're also a form of syntactic sugar). Anyway, I did set up a chat with the Chad (that article's author) and maybe we'll all get some more clarity. -- --Guido van Rossum (python.org/~guido)