ANN: engineering-units-0.0.1

Hi, I just uploaded a handy library for managing engineering units. It provides a Num type that allows you to mix units into calculations. It also converts between units automatically and will error out if you try to mix values with inconsistent units. Here's an example that computes the horsepower of a hydraulic pump (power = pressure * flow): flow = 20 * gpm -- Gallons per minute. pressure = 3000 * psi -- Pounds per square inch. power = pressure * flow powerHP = value power hp -- Get the value in horsepower. powerKW = value power kw -- Get the value in Kilowatts. If you don't see your units in the library, it's easy to add new ones: mm :: Value mm = 0.001 * m Wish I had this back in college. -Tom http://hackage.haskell.org/package/engineering-units

On Tue, Mar 11, 2014 at 11:30:44AM -0500, Tom Hawkins wrote:
Hi,
I just uploaded a handy library for managing engineering units. It provides a Num type that allows you to mix units into calculations. It also converts between units automatically and will error out if you try to mix values with inconsistent units.
Here's an example that computes the horsepower of a hydraulic pump (power = pressure * flow):
flow = 20 * gpm -- Gallons per minute. pressure = 3000 * psi -- Pounds per square inch. power = pressure * flow
powerHP = value power hp -- Get the value in horsepower. powerKW = value power kw -- Get the value in Kilowatts.
If you don't see your units in the library, it's easy to add new ones:
mm :: Value mm = 0.001 * m
Hi Tom, Looking at your documentation, I see a lot of sense behind implementing different units (Horsepower vs. Watts), but I'm not so sure about (for example) g/kg or m/cm/mm. These are just (SI) scaling factors, so should they be treated the same as individual units? For just the scaling factors, I released last year http://hackage.haskell.org/package/prefix-units, and I'm wondering if we couldn't somehow combine these two libraries. After all, "k" applies both to KG and KW :) thanks, iustin

On Tue, Mar 11, 2014 at 4:03 PM, Iustin Pop
Looking at your documentation, I see a lot of sense behind implementing different units (Horsepower vs. Watts), but I'm not so sure about (for example) g/kg or m/cm/mm. These are just (SI) scaling factors, so should they be treated the same as individual units?
Depends on if the difference shows up to the user. I've been using a calculator/scripting language (Frink) for years that has this kind of facility, and while I know that they are just scaling factors, I still treat them as different types of units. That may be because I grew up using imperial units, and inches/feet/yards/miles don't allow for being treated that way.
For just the scaling factors, I released last year http://hackage.haskell.org/package/prefix-units, and I'm wondering if we couldn't somehow combine these two libraries. After all, "k" applies both to KG and KW :)
Yes, but "KV" is not _always_ a kilovolt. When used on an electrical
motor, it's a measure of how many thousands of RPM you can expect the
motor to turn when for each volt of power it's fed. I'm hoping to get
around to desiging the power system for a multirotor this year, and
will be interesetd to see how various tools deal with this issue.

You may also be interested in the various flavors of Björn Buckwalter's
dimensional library.
On hackage it's dimensional-tf (for type families, and my preference) or
dimensional (for multi-parameter type classes).
We are working on making a version that takes advantage of the new GHC
DataKinds features to provide even more features, that's at
https://github.com/bjornbm/dimensional-dk.
-Doug
On Tue, Mar 11, 2014 at 4:26 PM, Mike Meyer
On Tue, Mar 11, 2014 at 4:03 PM, Iustin Pop
wrote: Looking at your documentation, I see a lot of sense behind implementing different units (Horsepower vs. Watts), but I'm not so sure about (for example) g/kg or m/cm/mm. These are just (SI) scaling factors, so should they be treated the same as individual units?
Depends on if the difference shows up to the user. I've been using a calculator/scripting language (Frink) for years that has this kind of facility, and while I know that they are just scaling factors, I still treat them as different types of units. That may be because I grew up using imperial units, and inches/feet/yards/miles don't allow for being treated that way.
For just the scaling factors, I released last year http://hackage.haskell.org/package/prefix-units, and I'm wondering if we couldn't somehow combine these two libraries. After all, "k" applies both to KG and KW :)
Yes, but "KV" is not _always_ a kilovolt. When used on an electrical motor, it's a measure of how many thousands of RPM you can expect the motor to turn when for each volt of power it's fed. I'm hoping to get around to desiging the power system for a multirotor this year, and will be interesetd to see how various tools deal with this issue.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- J. Douglas McClean (781) 561-5540 (cell)

Hello,
There are many libraries mentioned here too:
http://www.haskell.org/haskellwiki/Physical_units. I don't know of a
good comparison of the various options for runtime and compile-time
checked units.
Regards,
Adam
On Tue, Mar 11, 2014 at 4:36 PM, Douglas McClean
You may also be interested in the various flavors of Björn Buckwalter's dimensional library.
On hackage it's dimensional-tf (for type families, and my preference) or dimensional (for multi-parameter type classes).
We are working on making a version that takes advantage of the new GHC DataKinds features to provide even more features, that's at https://github.com/bjornbm/dimensional-dk.
-Doug
On Tue, Mar 11, 2014 at 4:26 PM, Mike Meyer
wrote: On Tue, Mar 11, 2014 at 4:03 PM, Iustin Pop
wrote: Looking at your documentation, I see a lot of sense behind implementing different units (Horsepower vs. Watts), but I'm not so sure about (for example) g/kg or m/cm/mm. These are just (SI) scaling factors, so should they be treated the same as individual units?
Depends on if the difference shows up to the user. I've been using a calculator/scripting language (Frink) for years that has this kind of facility, and while I know that they are just scaling factors, I still treat them as different types of units. That may be because I grew up using imperial units, and inches/feet/yards/miles don't allow for being treated that way.
For just the scaling factors, I released last year http://hackage.haskell.org/package/prefix-units, and I'm wondering if we couldn't somehow combine these two libraries. After all, "k" applies both to KG and KW :)
Yes, but "KV" is not _always_ a kilovolt. When used on an electrical motor, it's a measure of how many thousands of RPM you can expect the motor to turn when for each volt of power it's fed. I'm hoping to get around to desiging the power system for a multirotor this year, and will be interesetd to see how various tools deal with this issue.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- J. Douglas McClean
(781) 561-5540 (cell)
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

neat! Thanks for sharing. Seems like it'll be handy for sanity checking
physics ideas before writing the fancy realizations
On Tue, Mar 11, 2014 at 12:30 PM, Tom Hawkins
Hi,
I just uploaded a handy library for managing engineering units. It provides a Num type that allows you to mix units into calculations. It also converts between units automatically and will error out if you try to mix values with inconsistent units.
Here's an example that computes the horsepower of a hydraulic pump (power = pressure * flow):
flow = 20 * gpm -- Gallons per minute. pressure = 3000 * psi -- Pounds per square inch. power = pressure * flow
powerHP = value power hp -- Get the value in horsepower. powerKW = value power kw -- Get the value in Kilowatts.
If you don't see your units in the library, it's easy to add new ones:
mm :: Value mm = 0.001 * m
Wish I had this back in college.
-Tom
http://hackage.haskell.org/package/engineering-units
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (6)
-
adam vogt
-
Carter Schonwald
-
Douglas McClean
-
Iustin Pop
-
Mike Meyer
-
Tom Hawkins