[Haskell-cafe] ANN: engineering-units-0.0.1
Iustin Pop
iusty at k1024.org
Tue Mar 11 20:03:13 UTC 2014
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
More information about the Haskell-Cafe
mailing list