leema icon indicating copy to clipboard operation
leema copied to clipboard

add domain types

Open mdg opened this issue 6 years ago • 0 comments

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

mdg avatar Aug 14 '18 17:08 mdg