Safe Haskell | None |
---|---|
Language | Haskell2010 |
Caches for the raw API
- data FixerCache = FixerCache {}
- insertRates :: Day -> Day -> Rates -> FixerCache -> FixerCache
- data FixerCacheResult
- lookupRates :: Day -> Day -> Currency -> Symbols -> FixerCache -> FixerCacheResult
- emptyFixerCache :: FixerCache
- newtype RateCache = RateCache {}
- emptyRateCache :: RateCache
- insertRatesInCache :: Rates -> RateCache -> RateCache
- lookupRatesInCache :: Day -> Currency -> Symbols -> RateCache -> Maybe Rates
- smartInsertInCache :: Day -> Currency -> Currency -> Rate -> RateCache -> RateCache
- smartLookupRateInCache :: Day -> Currency -> Currency -> RateCache -> Maybe Rate
- defaultBaseCurrency :: Currency
- allSymbolsExcept :: Currency -> Symbols
- convertToBaseWithRate :: Currency -> Rate -> Rates -> Rates
- rawInsertInCache :: Day -> Currency -> Currency -> Rate -> RateCache -> RateCache
- rawLookupInCache :: Day -> Currency -> Currency -> RateCache -> Maybe Rate
Documentation
data FixerCache Source #
A complete cache for the raw API.
This includes a cache for the rates we get, as well as a cache for the rates we do not get.
:: Day | The current date |
-> Day | The requested date |
-> Rates | |
-> FixerCache | |
-> FixerCache |
Insert a given raw response in a FixerCache
data FixerCacheResult Source #
The result of looking up rates in a FixerCache
NotInCache | |
CacheDateNotInPast | Because we requested a date in the future |
WillNeverExist | Because it was on a weekend or holiday |
InCache Rates |
:: Day | The current date |
-> Day | The requested date |
-> Currency | |
-> Symbols | |
-> FixerCache | |
-> FixerCacheResult |
Look up rates in cache
emptyFixerCache :: FixerCache Source #
The empty FixerCache
A cache for currency rates
This cache uses EUR
as the base currency, but will still cache
rates appropriately if rates with a different base currency are cached.
emptyRateCache :: RateCache Source #
The empty Cache
insertRatesInCache :: Rates -> RateCache -> RateCache Source #
Insert a result into the cache.
This is probably the function you want to use, it does all the smartness.
lookupRatesInCache :: Day -> Currency -> Symbols -> RateCache -> Maybe Rates Source #
Look up multiple rates in a cache.
This function uses smartLookupRateInCache
for each requested symbol.
smartInsertInCache :: Day -> Currency -> Currency -> Rate -> RateCache -> RateCache Source #
Insert a rate in a cache, but don't insert it if the from and to currencies are the same.
smartLookupRateInCache :: Day -> Currency -> Currency -> RateCache -> Maybe Rate Source #
Look up a rate in a cache.
This function will try to be smart about what it can find, but will give up after one redirection.
defaultBaseCurrency :: Currency Source #
The default base currency. Currently this is EUR
allSymbolsExcept :: Currency -> Symbols Source #
The symbols to get by default, given a base currency.
convertToBaseWithRate :: Currency -> Rate -> Rates -> Rates Source #
Convert a set of rates to another base currency with the given rate of the new base currency with respect to the old base currency. In the map, we have the info that for 1 base currency, you get s of the currency in the key.
If we now say that for 1 of the old base currency, you can get r of the new base currency
This rate means for one of the new base currency, you can get s / r of the currency in the key.
rawInsertInCache :: Day -> Currency -> Currency -> Rate -> RateCache -> RateCache Source #
Insert a rate into the cache as-is.
You probably want to be using insertRatesInCache
or smartInsertInCache
instead.
rawLookupInCache :: Day -> Currency -> Currency -> RateCache -> Maybe Rate Source #
Lookup a rate in the cache as-is.
You probably want to be using smartLookupRateInCache
instead.