A Voltage
value represents a voltage (electric potential difference, if
we're being picky) in volts.
Since Volts
is defined as Rate Watts Amperes
(power per unit
current), you can do rate-related calculations with Voltage
values to compute
Power
or Current
:
// elm-units version of 'P = V * I'
power =
current |> Quantity.at voltage
// I = P / V
current =
power |> Quantity.at_ voltage
Just for fun, note that since you can also express Voltage
in terms of
Current
and Resistance
, you could rewrite the second example
above as
// P = I^2 * R
let power =
current
|> Quantity.at
(current
|> Quantity.at resistance
)