[Haskell-cafe] Request for Comments - hscurrency 0.0.1

Jason Dagit dagit at codersbase.com
Sat Aug 15 13:26:10 EDT 2009

On Sat, Aug 15, 2009 at 5:15 AM, Max Cantor <mxcantor at gmail.com> wrote:

> Hi all,
> I'm putting together some simple tools to do safe calculations on different
> currencies.  For instance, making sure that you dont add something like 5
> USD + 10 JPY without doing a proper conversion.
> I've put up some code on google code which probably explains what I'm
> trying to do more succinctly than this email.  I'm curious what poeple think
> about the library, its the first haskell code I've written for the purpose
> of sharing and I intend to add it to hackage once I finalize the interface a
> bit more.
> The code is at: http://bit.ly/1Cjjlj
> I'm very open to suggestions on improving the interface.  RIght now its
> very simple and straightforward but potentially limited.

Right now it looks like you have taken the approach of embedded domain
specific language.  You have not exposed the currency units to the type
system.  Therefore you rely on the rules of your embedded language to do
proper conversions.

Have you considered exposing the type information to the type checker?  A
similar question came up recently on a Portland functional programming
mailing list and my reply can be found here:

The experimental code which resulted is here:

You may also want to look at the dimensional package:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090815/5da2865e/attachment.html

More information about the Haskell-Cafe mailing list