Skip to content

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

@adam-mcdaniel

Description

@adam-mcdaniel

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions