HealthSamurai / unit-map

Eclipse Public License 1.0
16 stars 8 forks source link

Add parametric polymorphism #41

Open KGOH opened 4 years ago

KGOH commented 4 years ago

Do not check type, but sets of units instead. (i.e. treat as parameters units involved in operation)

Result value should have type of the left operand either more broader type of the right operand if left operand's type can't hold the result value

Example: ^:date{:year 2020, :month 9, :day 9} + ^{:datetime :delta}{:day 1} = ^:date{:year 2020, :month 9, :day 10} But ^:date{:year 2020, :month 9, :day 9} + ^{:datetime :delta}{:day 1, :hour 1} = ^:datetime{:year 2020, :month 9, :day 10, :hour 1} And ^:datetime{:year 2020, :month 9, :day 9} + ^{:date :delta}{:day 1} = ^:datetime{:year 2020, :month 9, :day 10}

KGOH commented 4 years ago

There is no guarantee that same units of the different types have the same definition. Should we consider comparsion not only by units but by their sequences too? Should we allow them to be different?