3 ms·
Yes, a “Sum” type in Type Theory
by alfiedotwtf 2y ago
Yes, a “Sum” type in Type Theory
- magicalhippo 2y agoWell it's more like a dynamically defined sum type, no? There's also the scaffolding around it, like the way error codes compare for equivalence[1] against error conditions in a symmetric way[2]. The result is you can easily add new a domain-specific error category, and error codes using your new category can be fed to existing code and they'll do something sensible without further modification. Your code with the new category could even be loaded at runtime[3]. Not something you can do with plain sum types, ie tagged unions in C. At least as far as I know, though I'm no expert. [1]: https://www.boost.org/doc/libs/1_82_0/libs/system/doc/html/system.html#usage_testing_for_specific_error_conditions https://www.boost.org/doc/libs/1_82_0/libs/system/doc/html/s... [2]: https://www.boost.org/doc/libs/1_82_0/libs/system/doc/html/system.html#ref_comparisons_2 https://www.boost.org/doc/libs/1_82_0/libs/system/doc/html/s... [3]: though there might be dragons, see my previous reference