[Python-ideas] "Sum" Type hinting [was: Type hinting for path-related functions]

Koos Zevenhoven k7hoven at gmail.com
Mon May 16 10:45:41 EDT 2016


On Mon, May 16, 2016 at 4:57 AM, Guido van Rossum <guido at python.org> wrote:
[...]
> unions in Python are always tagged (since you can always introspect the object type).

I suppose that is true at runtime, at least if the pairwise
intersections of the "arguments" of the union are empty as they
usually are. But for a static type checker, the "tag" for the Union
may be missing (which is the thing I was worried about).

[...]
> in Haskell as in PEP 484, Sum types and generics are pretty much orthogonal
> concepts.

Although the parametrization provided by generics make TypeVars more
powerful for annotating functions that deal with the equivalent of sum
types.

-- Koos


More information about the Python-ideas mailing list