ianmackenzie/elm-units-prefixed/2.7.0

NOTE: the latest version is 2.8.0

Units.Voltage

A Voltage value represents a voltage (electric potential difference, if we're being picky) in volts.

Note that 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
power =
    current
        |> Quantity.at
            (current
                |> Quantity.at resistance
            )
type alias Voltage =
Voltage
type alias Volts =
Volts
volts : Float -> Voltage

Construct a voltage from a number of volts.

inVolts : Voltage -> Float

Convert a voltage to a number of volts.