If I have some simple sum type in Haskell, like
data Owner = Me | You
How do I express that in Python in a convenient way?
An Enum or a Union is the closest thing to a tagged union or sum type in Python.
from enum import Enum
class Owner(Enum):
Me = 1
You = 2
https://docs.python.org/3/library/typing.html#typing.Union
import typing
class Me:
pass
class You:
pass
owner: typing.Union[Me, You] = Me