leema
leema copied to clipboard
add domain types
Domain types (in leema) are type aliases that can only be aliased in one direction. They are to be used when constraining the values of a type to a particular, domain-specific subset of the values otherwise allowed by the type.
For example, imagine a domain type for a zip code that is aliased to a string. Once you create a zip code, you can pass it to a function that takes a string. But if you have a function that takes a zip code, you cannot pass it a string without first explicitly converting it to a zip code type.
This might function similarly to an implicit cast operator in C++. https://en.cppreference.com/w/cpp/language/cast_operator