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

Greg Ewing greg.ewing at canterbury.ac.nz
Sun May 15 19:37:46 EDT 2016


Koos Zevenhoven wrote:

> Maybe you mean to propose that the concept of sum types should be
> introduced in typing/mypy.

I'm not deeply into category theory, but the proposal
seems to be that Sum would be a special kind of type
that's assumed to be the same type wherever it appears
in the signature of a function.

That might work for the special case of a function of
one parameter that returns the same type as its
argument, but that's about all.

As has been pointed out, type parameters allow the
same thing to be expressed, and a lot more besides,
so a Sum type is not needed. We already have everything
we neeed.

-- 
Greg


More information about the Python-ideas mailing list