import :std: unit km unit mile # Because km and mile are not subunits # of arith, the normal add won't match. # But here we match and re-apply with empty # units, then re-attach the unit in the end. def add[u](a: int {u}, b: int {u}): return (a {} + b {}) {u} def main(_): print(add(1 {km})(2 {km})) # EXECUTE # 3 km