Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Unfortunately, "Num" isn't precisely what you want in money - you don't multiply dollars by dollars to get dollars...

But it works well enough.



Rather than arbitrary multiplication, you should probably have an OrderUnits type, then define a function of type Money -> OrderUnits -> Money that calculates the price of multiple units.

(Money 3 * 2 will return Money 6 if fromIntegral 2 = Money 2. But that is not really the operation you want to perform, so you might consider not implementing Num for Money.)


Right, exactly.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: