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.
A
Unit
type traditionally means theNone
type in common nomenclature.Currently, the
Unit
type in Sage is a type that enforces structural equality and nominal equality. AUnit(Meter, Int)
is not equal to anInt
, or aUnit(Kilometer, Int)
; it is only equal to anotherUnit(Meter, Int)
, where the inner types are structurally equal. AnInt
can be cast to aUnit(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
, orNominal
could be used instead.