3 ms·
Specifically, closed sum types. You can usually get open sum types by way of inheritance.
by dllthomas 5y ago
Specifically, closed sum types. You can usually get open sum types by way of inheritance.
- globuous 5y agoTrue that! It was eye opening once I understood that! Here's a basic type system I made in Python for a small smart contract language compiler I'm working on. It works with mypy pretty flawlessly! [1] I still haven't figured out how to prevent subclassing with methods that don't comply with a specific type signature, but that's a story for another day... [1] https://yourlabs.io/pyratzlabs/pymich/-/blob/master/pymich/michelson_types.py https://yourlabs.io/pyratzlabs/pymich/-/blob/master/pymich/m...