[Haskell-cafe] What is a safe Haskell data type to store and manipulate Money values?

David Turner dct25-561bs at mythic-beasts.com
Tue Apr 4 15:10:46 UTC 2017


On 4 April 2017 at 15:50, Joachim Durchholz <jo at durchholz.org> wrote:

> Am 04.04.2017 um 16:13 schrieb ALeX Kazik:
>
>> Leaving aside the legal aspects of this, what would be Haskell's
>>> equivalent
>>> of the BigDecimal format in Java (or Ruby)? Decimal (as used by hledger)?
>>>
>>
>> Rational?
>>
>
> You'd be constantly be doing explicit calculations to get back to a
> denominator of 100. Plus you'd have to deal with those cases where the
> denominator is a divisor of 100, and you'd need explicit nonstandard
> conversion to strings.



The same sort of fiddling-the-denominator problems also occur if you use
`Decimal` - it's not normally useful to be able to represent things smaller
than £0.01 (or whatever the smallest unit of your local currency is); I'd
even go as far as to say it's useful to be able to be sure that you _can't_
represent such things (in the domain of basic accounting at least - more
complex things may deal with smaller fractions of currency, so YMMV etc).

Cheers,





>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170404/214b13ee/attachment.html>


More information about the Haskell-Cafe mailing list