[Haskell-cafe] [Haskell] [ANN] quantities 0.3.0
John David Reaver
jdreaver at adlerhorst.com
Tue Apr 15 20:30:38 UTC 2014
Thanks for the feedback!
> not sure if "quantities" is an appropriate name for your
> package: an integer, a float, complex numbers - those are
> quantities. doesn't this package parse units?
Wikipedia and this dictionary
(http://dictionary.reference.com/browse/quantity) imply that
quantities are associated with units of measurement. This package
does indeed parse units. When a magnitude is associated with
those units, you get a quantity. I think the name "quantities" is
> why can i only "unsafely" create quantities using strings? what
> if i know upfront what kind of a unit i want to deal with? from
> the looks of it, this library is only good for dealing with
> human-readable input - surely that's not the only use case you
> had in mind?
> can't we find some elegant way to express this in haskell,
> instead of having to invent a scripting language of sorts?
Using the type system to handle units is incorporated into some
other libraries. I couldn't find a library that parses units from
strings, so I made one. I certainly plan to add this
functionality in the future.
> On a similar note, your "magnitude :: Quantity -> Double"
> sounds a bit like unsafeCoerce: why would you want to forget
> that your quantity has a unit?
You don't "forget" it has units. Sometimes you just want to get
the magnitude, like after you perform a conversion operation, for
> Oh, so you are trying to support arbitrary arithmetical input!
> Then again, there is no way to add two "Quantity"s.
There is indeed:
> I have the feeling the goal of your package is a bit unclear:
> do you want to implement a framework to type-safely compute
> with units? Or do you just want to write something that parses
> string input to typed data?
Currently, it parses string input. I am a contributor to a Python
package called pint, which was a huge inspiration to this library.
In my day job, I develop a commercial Python GUI application for
petroleum engineering that needs to convert between many units.
One feature of this application is a user can enter arbitrary
units of their choice to for plots and data so they don't have to
convert units by hand when using the application. I wanted to
bring that functionality to Haskell.
> Well, that was a big rant, I hope you can use some of it.
I did, thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe