Safe Haskell | None |
---|---|
Language | Haskell2010 |
The top-level API for the Haskell Fixer client.
There is an example usage in the README
file.
- data FClient a
- autoRunFixerClient :: FClient a -> IO (Either ServantError a)
- data RatesResult
- getLatest :: Maybe Currency -> Maybe Symbols -> FClient RatesResult
- getAtDate :: Day -> Maybe Currency -> Maybe Symbols -> FClient RatesResult
- withFileCache :: FilePath -> FClient a -> FClient a
- data Currency
- newtype Symbols = Symbols {}
- data Rate
- data Rates = Rates {}
- oneRate :: Rate
- mulRate :: Rate -> Rate -> Rate
- divRate :: Rate -> Rate -> Rate
- rateToDouble :: Rate -> Double
- data NonEmpty a :: * -> * = a :| [a]
- data Day :: *
- fromGregorian :: Integer -> Int -> Int -> Day
Documentation
A client function
autoRunFixerClient :: FClient a -> IO (Either ServantError a) Source #
Run a FClient
action and figure out the ClientEnv
and FixerCache
arguments automatically.
This is probably the function you want to use
data RatesResult Source #
The result of calling the API the local cache
DateNotInPast | because you tried to call the API for a future date |
RateDoesNotExist | because the date is on a weekend, for example |
RatesFound Rates |
getLatest :: Maybe Currency -> Maybe Symbols -> FClient RatesResult Source #
Get the latest rates.
Note that this function fetches the latest rates, but that does not mean
that the latest symbols appeared on the current date. However, there is no
way to predict what date the last rates appeared on, so we still look in the
cache at the current date. For maximum cache hits, use getAtDate
and only
look at the past beyond the last three days.
getAtDate :: Day -> Maybe Currency -> Maybe Symbols -> FClient RatesResult Source #
Get the rates at a specific date.
withFileCache :: FilePath -> FClient a -> FClient a Source #
Declare that we want to use the given file as a persistent cache.
Note that FClient
will still use a per-run cache if this function is not used.
This function only makes sure that the cache is persistent accross runs.
withFileCache path func = do readCacheFromFileIfExists path r <- func flushCacheToFile path pure r
Types
A sum-type of the supported currencies on fixer.io
AUD | |
BGN | |
BRL | |
CAD | |
CHF | |
CNY | |
CZK | |
DKK | |
EUR | |
GBP | |
HKD | |
HRK | |
HUF | |
IDR | |
ILS | |
INR | |
JPY | |
KRW | |
MXN | |
MYR | |
NOK | |
NZD | |
PHP | |
PLN | |
RON | |
RUB | |
SEK | |
SGD | |
THB | |
TRY | |
USD | |
ZAR |
A nonempty list of Currency
s
A positive and non-0 ratio
The raw response of fixer.io
rateToDouble :: Rate -> Double Source #
Convert a rate to a Double
.
This may not be a lossless transformation
Re-exports
NonEmpty
Non-empty (and non-strict) list type.
Since: 4.9.0.0
a :| [a] infixr 5 |
Monad NonEmpty | Since: 4.9.0.0 |
Functor NonEmpty | Since: 4.9.0.0 |
MonadFix NonEmpty | Since: 4.9.0.0 |
Applicative NonEmpty | Since: 4.9.0.0 |
Foldable NonEmpty | Since: 4.9.0.0 |
Traversable NonEmpty | Since: 4.9.0.0 |
ToJSON1 NonEmpty | |
FromJSON1 NonEmpty | |
Eq1 NonEmpty | Since: 4.10.0.0 |
Ord1 NonEmpty | Since: 4.10.0.0 |
Read1 NonEmpty | Since: 4.10.0.0 |
Show1 NonEmpty | Since: 4.10.0.0 |
MonadZip NonEmpty | Since: 4.9.0.0 |
IsList (NonEmpty a) | Since: 4.9.0.0 |
Eq a => Eq (NonEmpty a) | |
Data a => Data (NonEmpty a) | |
Ord a => Ord (NonEmpty a) | |
Read a => Read (NonEmpty a) | |
Show a => Show (NonEmpty a) | |
Generic (NonEmpty a) | |
Semigroup (NonEmpty a) | Since: 4.9.0.0 |
ToJSON a => ToJSON (NonEmpty a) | |
FromJSON a => FromJSON (NonEmpty a) | |
Validity a => Validity (NonEmpty a) | A nonempty list is valid if all the elements are valid. See the instance for 'Validity [a]' for more information. |
Generic1 * NonEmpty | |
type Rep (NonEmpty a) | |
type Item (NonEmpty a) | |
type Rep1 * NonEmpty | |
Date
The Modified Julian Day is a standard count of days, with zero being the day 1858-11-17.
Enum Day | |
Eq Day | |
Data Day | |
Ord Day | |
Ix Day | |
ToJSON Day | |
ToJSONKey Day | |
FromJSON Day | |
FromJSONKey Day | |
NFData Day | |
ToFormKey Day | |
FromFormKey Day | |
ToHttpApiData Day |
|
FromHttpApiData Day |
|
ParseTime Day | |