Closed ianmackenzie closed 5 years ago
Tweaked API: repurpose times
for products (just use at
and at_
for rate multiplications) and use over
for division of a product, so everything is "infix"/pipeline-friendly like most other functions in Quantity
:
times:
Quantity number units2
-> Quantity number units1
-> Quantity number (Product units1 units2)
over:
Quantity Float units2
-> Quantity Float (Product units1 units2)
-> Quantity Float units1
over_:
Quantity Float units1
-> Quantity Float (Product units1 units2)
-> Quantity Float units2
This leads to code like
force =
mass |> Quantity.times acceleration
acceleration =
force |> Quantity.over_ mass
mass =
force |> Quantity.over acceleration
area =
width |> Quantity.times height
volume =
width |> Quantity.times height |> Quantity.times depth
volume =
area |> Quantity.times depth -- NOT depth times area
depth =
volume |> Quantity.over_ area
area =
volume |> Quantity.over depth
(This assumes that Newtons
are redefined as Product Kilograms MetersPerSecondSquared
instead of the current Rate Joules Meters
.)
Implemented and released as part of version 2.0.
Add
Then redefine
Squared
andCubed
asRedefine
product
asThis will allow for
and perhaps
This will be a major version change, although it shouldn't actually break any change (all existing type aliases in user code should still be valid, since the
Squared
type is replaced by the equivalentSquared
type alias).