<br><br><div class="gmail_quote">On Sat, Aug 15, 2009 at 5:15 AM, Max Cantor <span dir="ltr">&lt;<a href="mailto:mxcantor@gmail.com">mxcantor@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi all,<br>
<br>
I&#39;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.<br>
<br>
I&#39;ve put up some code on google code which probably explains what I&#39;m trying to do more succinctly than this email.  I&#39;m curious what poeple think about the library, its the first haskell code I&#39;ve written for the purpose of sharing and I intend to add it to hackage once I finalize the interface a bit more.<br>

<br>
The code is at: <a href="http://bit.ly/1Cjjlj" target="_blank">http://bit.ly/1Cjjlj</a><br>
<br>
I&#39;m very open to suggestions on improving the interface.  RIght now its very simple and straightforward but potentially limited.</blockquote><div><br>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.<br>
<br>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:<br><a href="http://groups.google.com/group/pdxfunc/tree/browse_frm/month/2009-08/5c565768ecf30c57?rnum=1&amp;_done=%2Fgroup%2Fpdxfunc%2Fbrowse_frm%2Fmonth%2F2009-08%3F#doc_5c565768ecf30c57">http://groups.google.com/group/pdxfunc/tree/browse_frm/month/2009-08/5c565768ecf30c57?rnum=1&amp;_done=%2Fgroup%2Fpdxfunc%2Fbrowse_frm%2Fmonth%2F2009-08%3F#doc_5c565768ecf30c57</a><br>
<br>The experimental code which resulted is here:<br><a href="http://gist.github.com/165691">http://gist.github.com/165691</a><br><br>You may also want to look at the dimensional package:<br><a href="http://code.google.com/p/dimensional/">http://code.google.com/p/dimensional/</a><br>
<br>Jason<br></div></div>