Chadtech / elm-money

All the worlds currencies.
https://package.elm-lang.org/packages/Chadtech/elm-money/latest/
MIT License
13 stars 2 forks source link

Operations on currencies? #6

Open sgioia9 opened 5 years ago

sgioia9 commented 5 years ago

Hey!

Just wondering if you're open to work on implementing operations on currencies?

I'd like to do stuff like being able to define exchange rates, add, multiply, substract, etc, different currencies. I was starting to roll my own exchange module and was thinking about adding a way to use currencies from this package, but before I did that I wanted to ask if you're down to considering implementing these things here (which I think makes sense).

Chadtech commented 5 years ago

Hey @sgioia9 , I just saw your slack message. Thanks for reaching out.

Yes that would be very nice to implement exchange rate stuff. I dont have any thoughts on it. I havent ever had to do exchange rates before, so I dont have a clear picture of the use case. Do you have ideas? Would you like to contribute exchange rate functionality to elm-money? (That would be very much appreciated, I'd make sure to give you credit in the readme).

What are your thoughts tho? Just, as I understand it, you would have to fetch the latest exchange rate for, say, USD to EUR, and you get back a number in the http response like 1.15, and then you have to hang onto that 1.15 number so you can divide your USD by the exchange rate to see the equivalent in EUR?

Are you imagining functions like?

getExchangeRate : { from : Code, to : Code } -> ExchangeRates -> Maybe Float

convert : { from: Code, to: Code } -> ExchangeRates -> Int -> Maybe Int

Thanks,