sage icon indicating copy to clipboard operation
sage copied to clipboard

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

Open adam-mcdaniel opened this issue 1 year ago β€’ 0 comments

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 avatar Jun 14 '23 01:06 adam-mcdaniel