Timeline for answer to How can I define algebraic data types in Python? by Brent
Current License: CC BY-SA 4.0
Post Revisions
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 14, 2024 at 12:09 | comment | added | chepner |
Sum and union types are two different things. None | None, for example, is isomorphic (if not identical) to None itself. None + None (to use the obvious syntax for a hypothetical sum type) would be isomorphic to bool.
|
|
| Oct 15, 2021 at 19:17 | comment | added | Brent | As of today (October 15 2021) Python 3.10 is released, adding support for structural pattern matching. docs.python.org/3.10/whatsnew/… | |
| May 12, 2021 at 13:56 | comment | added | Timmmm | This isn't really sum types since it just relies on RTTI to identify the type. | |
| Dec 9, 2020 at 10:52 | comment | added | Martin Stancsics | And PEP 622 (pattern matching) makes using sum types even more similar to functional languages. | |
| Nov 5, 2020 at 10:40 | comment | added | Noé Rubinstein |
Hi! If you are using mypy, you can check the exhaustiveness of your "pattern matching" using the assert_never idiom: github.com/python/typing/issues/735
|
|
| Oct 28, 2020 at 18:07 | history | answered | Brent | CC BY-SA 4.0 |