Skip to content

Add functions to convert between different forms of the same quantity type #32

@ianmackenzie

Description

@ianmackenzie

All just no-ops that just convert between equivalent units types:

  • Force.energyPerLength : Quantity Float (Rate Joules Meters) -> Force
  • Force.asEnergyPerLength : Force -> Quantity Float (Rate Joules Meters)
  • Energy.massTimesSpeedSquared : Quantity Float (Product Kilograms (Squared MetersPerSecondSquared)) -> Energy
  • Energy.asMassTimesSpeedSquared : Energy -> Quantity Float (Product Kilograms (Squared MetersPerSecondSquared))

Possible breaking change: perhaps then switch back to Force, Energy etc. having their own units types, e.g.

type Newtons
    = Newtons

instead of

type alias Newtons =
    Product Kilograms MetersPerSecondSquared

and then always convert to/from rates/products where needed. More symmetric (doesn't 'bless' one particular representation as the canonical one), and perhaps less confusing - always need to cast to a rate/product if you need one. In this case we would also need

  • Force.massTimesAcceleration : Quantity Float (Product Kilograms MetersPerSecondSquared) -> Force
  • Force.asMassTimesAcceleration : Force -> Quantity Float (Product Kilograms MetersPerSecondSquared)
  • Energy.forceTimesLength : Quantity Float (Product Newtons Meters) -> Energy
  • Energy.asForceTimesLength : Energy -> Quantity Float (Product Newtons Meters)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions