Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change crate::lir::types::Type::Unit(Name, Ty) to a better name, like ..::Type::Nominal(..) #38

Open
adam-mcdaniel opened this issue Jun 14, 2023 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@adam-mcdaniel
Copy link
Owner

adam-mcdaniel commented Jun 14, 2023

A Unit type traditionally means the None type in common nomenclature.

Currently, the Unit type in Sage is a type that enforces structural equality and nominal equality. A Unit(Meter, Int) is not equal to an Int, or a Unit(Kilometer, Int); it is only equal to another Unit(Meter, Int), where the inner types are structurally equal. An Int can be cast to a Unit(Meter, Int) and vice versa. This adds functionality to the type system to typecheck against using a "Meter" where a "Kilometer" is required, even though the data used to represent both the types is the same. It forces the user to perform the unit conversion at the type system level.

I'm thinking a name like Unique, or Nominal could be used instead.

@adam-mcdaniel adam-mcdaniel changed the title Change Type::Unit(Name, Ty) to a better name. Change crate::lir::types::Type::Unit(Name, Ty) to a better name. Jun 14, 2023
@adam-mcdaniel adam-mcdaniel changed the title Change crate::lir::types::Type::Unit(Name, Ty) to a better name. Change crate::lir::types::Type::Unit(Name, Ty) to a better name, like ...::Type::Nominal Jun 14, 2023
@adam-mcdaniel adam-mcdaniel changed the title Change crate::lir::types::Type::Unit(Name, Ty) to a better name, like ...::Type::Nominal Change crate::lir::types::Type::Unit(Name, Ty) to a better name, like ..::Type::Nominal(..) Jun 14, 2023
@adam-mcdaniel adam-mcdaniel added enhancement New feature or request good first issue Good for newcomers labels Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant