[Haskell-cafe] Re: money type ?

Donald Bruce Stewart dons at cse.unsw.edu.au
Thu Jul 12 05:17:11 EDT 2007


simon:
> Great - indeed,
> 
> > sum [1.85, 5.95, -7.80]
> 8.881784197001252e-16
> > sum [1.85::Money, 5.95, -7.80]
> 0.00
> 
> I'm not yet sure these will do the best thing in all arithmetic, but it 
> seems to be the right thing for now.
> 
> Yes, I will need to read these also. Perhaps first reading the integer and 
> decimal digits as separate integers will help. I'm still exploring the 
> number types.

Roman Leschinskiy tells me that there are C (or C++?)  libraries for
locale-specific money handling, where given precisions are mandated in
particular countries, below which you must round. Perhaps we should have
a binding to this.

Anyway, sorting out how money is supposed to be represented in Haskell,
and documenting it, seems a very useful thing.

-- Don


More information about the Haskell-Cafe mailing list