Skip to content

add domain types #3

Description

@mdg

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions