/* SI Prelude */ //: SI Units type normal Second :: Unit; //Unit is the Kind of SI Unit types. type normal Metre :: Unit; //Kinds do not need to be declared before use. type normal Gram :: Unit; type normal Ampere :: Unit; type normal Kelvin :: Unit; type normal Mole :: Unit; type normal Candela :: Unit; //: Imperial & Misc. Units type Feet :: Unit; forall u:Feet::Unit. Feet => Metre = 0.3048*u :: Unit; forall u:Metre::Unit. Metre => Feet = u/0.3048 :: Unit; type Yard :: Unit; forall u:Yard::Unit. Yard => Metre = 0.9144*u :: Unit; forall u:Metre::Unit. Metre => Yard = u/0.9144 :: Unit; type Mile :: Unit; forall u:Mile::Unit. Mile => Metre = 1609.34*u :: Unit; forall u:Metre::Unit. Metre => Mile = u/1609.34 :: Unit; type Minute :: Unit; forall u:Minute::Unit. Minute => Second = 60*u :: Unit; forall u:Second::Unit. Second => Minute = u/60 :: Unit; type Hour :: Unit; forall u:Hour::Unit. Hour => Second = 3600*u :: Unit; forall u:Second::Unit. Second => Hour = u/3600 :: Unit; //: Dimensionless Units type normal Radian :: Unit; type normal Steradian :: Unit; //: SI Derived Units (source: https://www.ece.utoronto.ca/canadian-metric-association/si-derived-units/) type Hertz: ()/Second :: Unit; type Newton: Metre*Kilo/Second*Second :: Unit; type Pascal: Kilo/Metre*Second*Second :: Unit; type Joule: Kilo*Metre*Metre/Second*Second :: Unit; type Watt: Kilo*Metre*Metre/Second*Second*Second :: Unit; type Coulomb: Ampere*Second :: Unit; //The constant value of a Coulomb is no longer exactly 1 Ampere Second but the Unit remains unchanged type Volt: Kilo*Metre*Metre/Ampere*Second*Second*Second :: Unit; type Ohm: Kilo*Metre*Metre/Ampere*Ampere*Second*Second*Second :: Unit; type Siemens: Ampere*Ampere*Second*Second*Second/Kilo*Metre*Metre :: Unit; type Farad: Ampere*Ampere*Second*Second*Second*Second/Kilo*Metre*Metre :: Unit; type Tesla: Kilo/Ampere*Second*Second :: Unit; type Weber: Kilo*Metre*Metre/Ampere*Second*Second :: Unit; type Henry: Kilo*Metre*Metre/Ampere*Ampere*Second*Second :: Unit; type Lumen: Candela*Steradian :: Unit; type Lux: Candela*Steradian/Metre*Metre :: Unit; type Becquerel: ()/Second :: Unit; type Gray: Metre*Metre/Second*Second :: Unit; type Sievert: Metre*Metre/Second*Second :: Unit; type SquareMetre: Metre*Metre :: Unit; type CubicMetre: Metre*Metre*Metre :: Unit; type Speed: Metre/Second :: Unit; type Acceleration: Metre/Second*Second :: Unit; type Jerk: Metre/Second*Second*Second :: Unit; type Wavenumber: ()/Metre :: Unit; type Density: Kilo/Metre*Metre*Metre :: Unit; type SurfaceDensity: Kilo/Metre*Metre :: Unit; type SpecificVolume: Metre*Metre*Metre/Kilo :: Unit; type CurrentDensity: Ampere/Metre*Metre :: Unit; type MagneticFieldStrength: Ampere/Metre :: Unit; type Concentration: Mole/Metre*Metre*Metre :: Unit; type MassConcentration: Kilo/Metre*Metre*Metre :: Unit; type Luminance: Candela/Metre*Metre :: Unit; type RefractiveIndex :: Unit; type RelativePermeability :: Unit; //: SI Metric Prefixes type Yotta :: Unit; type Zetta :: Unit; type Exa :: Unit; type Peta :: Unit; type Tera :: Unit; type Giga :: Unit; type Mega :: Unit; type Kilo :: Unit; type Hecto :: Unit; type Deca :: Unit; type Deci :: Unit; type Centi :: Unit; type Milli :: Unit; type Micro :: Unit; type Nano :: Unit; type Pico :: Unit; type Femto :: Unit; type Atto :: Unit; type Zepto :: Unit; type Yocto :: Unit; //: SI Metric Prefixes, boxing forall u:U::Unit. U => Yotta = 1000000000000000000000000 * u :: Unit; forall u:U::Unit. U => Zetta = 1000000000000000000000 * u :: Unit; forall u:U::Unit. U => Exa = 1000000000000000000 * u :: Unit; forall u:U::Unit. U => Peta = 1000000000000000 * u :: Unit; forall u:U::Unit. U => Tera = 1000000000000 * u :: Unit; forall u:U::Unit. U => Giga = 1000000000 * u :: Unit; forall u:U::Unit. U => Mega = 1000000 * u :: Unit; forall u:U::Unit. U => Kilo = 1000 * u :: Unit; forall u:U::Unit. U => Hecto = 100 * u :: Unit; forall u:U::Unit. U => Deca = 10 * u :: Unit; forall u:U::Unit. U => Deci = u / 10 :: Unit; forall u:U::Unit. U => Centi = u / 100 :: Unit; forall u:U::Unit. U => Milli = u / 1000 :: Unit; forall u:U::Unit. U => Micro = u / 1000000 :: Unit; forall u:U::Unit. U => Nano = u / 1000000000 :: Unit; forall u:U::Unit. U => Pico = u / 1000000000000 :: Unit; forall u:U::Unit. U => Femto = u / 1000000000000000 :: Unit; forall u:U::Unit. U => Atto = u / 1000000000000000000 :: Unit; forall u:U::Unit. U => Zepto = u / 1000000000000000000000 :: Unit; forall u:U::Unit. U => Yocto = u / 1000000000000000000000000 :: Unit; //: SI Metric Prefixes, unboxing forall u:Yotta::Unit. Yotta => U = u / 1000000000000000000000000 :: Unit; forall u:Zetta::Unit. Zetta => U = u / 1000000000000000000000 :: Unit; forall u:Exa::Unit. Exa => U = u / 1000000000000000000 :: Unit; forall u:Peta::Unit. Peta => U = u / 1000000000000000 :: Unit; forall u:Tera::Unit. Tera => U = u / 1000000000000 :: Unit; forall u:Giga::Unit. Giga => U = u / 1000000000 :: Unit; forall u:Mega::Unit. Mega => U = u / 1000000 :: Unit; forall u:Kilo::Unit. Kilo => U = u / 1000 :: Unit; forall u:Hecto::Unit. Hecto => U = u / 100 :: Unit; forall u:Deca::Unit. Deca => U = u / 10 :: Unit; forall u:Deci::Unit. Deci => U = 10 * u :: Unit; forall u:Centi::Unit. Centi => U = 100 * u :: Unit; forall u:Milli::Unit. Milli => U = 1000 * u :: Unit; forall u:Micro::Unit. Micro => U = 1000000 * u :: Unit; forall u:Nano::Unit. Nano => U = 1000000000 * u :: Unit; forall u:Pico::Unit. Pico => U = 1000000000000 * u :: Unit; forall u:Femto::Unit. Femto => U = 1000000000000000 * u :: Unit; forall u:Atto::Unit. Atto => U = 1000000000000000000 * u :: Unit; forall u:Zepto::Unit. Zepto => U = 1000000000000000000000 * u :: Unit; forall u:Yocto::Unit. Yocto => U = 1000000000000000000000000 * u :: Unit; //: SI Constants let si_c: Metre/Second = 299_792_458; //speed of light in vacuum let si_h: Joule*Second = 6.626_070_15e-34; //Planck constant let si_e: Coulomb = 1.602_176_634e-19; //elementary charge let si_k: Joule/Kelvin = 1.380_649e-23; //Boltzmann constant let si_k_cd: Lumen/Watt = 683; //luminous efficacy of a defined visible radiation let si_n_A: ()/Mole = 6.022_140_76e23; //Avogadro constant let si_deltavCs: Hertz = 9_192_631_770; //caesium hyperfine frequency //: Unit Math let pos(x:X::Unit) :X ::Unit; //pos let neg(x:X::Unit) :X ::Unit; //neg let $"+"(x:X::Unit, y:X::Unit) :X ::Unit; //add let $"-"(x:X::Unit, y:X::Unit) :X ::Unit; //sub let $"*"(x:X::Unit, y:Y::Unit) :X*Y ::Unit; //mul let $"*"(x:Number, y:Y::Unit) :Y ::Unit; //mul constant let $"*"(x:X::Unit, y:Number) :X ::Unit; //mul constant let $"/"(x:X::Unit, y:Y::Unit) :X/Y ::Unit; //div let $"/"(x:Number, y:Y::Unit) :()/Y::Unit; //div constant let $"/"(x:X::Unit, y:Number) :X ::Unit; //div constant