-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A Haskell client for http://fixer.io/ -- -- Please see the README on Github at -- https://github.com/NorfairKing/fixer#readme @package fixer @version 0.0.0.0 -- | Types for the API module Fixer.Types -- | A positive and non-0 ratio newtype Rate Rate :: Ratio Natural -> Rate [unRate] :: Rate -> Ratio Natural -- | The identity of mulRate oneRate :: Rate -- | Multiply two rates mulRate :: Rate -> Rate -> Rate -- | Divide one rate by another divRate :: Rate -> Rate -> Rate -- | Ensure that a rate is internally normalised. This is a requirement for -- Validity normaliseRate :: Rate -> Rate -- | Convert a rate to a 'Ratio Integer' instead of 'Ratio Natural'. -- -- This is a lossless transformation. rateToRational :: Rate -> Rational -- | Convert a rate to a Double. -- -- This may not be a lossless transformation rateToDouble :: Rate -> Double -- | A sum-type of the supported currencies on fixer.io data Currency AUD :: Currency BGN :: Currency BRL :: Currency CAD :: Currency CHF :: Currency CNY :: Currency CZK :: Currency DKK :: Currency EUR :: Currency GBP :: Currency HKD :: Currency HRK :: Currency HUF :: Currency IDR :: Currency ILS :: Currency INR :: Currency JPY :: Currency KRW :: Currency MXN :: Currency MYR :: Currency NOK :: Currency NZD :: Currency PHP :: Currency PLN :: Currency RON :: Currency RUB :: Currency SEK :: Currency SGD :: Currency THB :: Currency TRY :: Currency USD :: Currency ZAR :: Currency -- | A nonempty list of Currencys newtype Symbols Symbols :: NonEmpty Currency -> Symbols [unSymbols] :: Symbols -> NonEmpty Currency -- | The raw response of fixer.io data Rates Rates :: Currency -> Day -> Map Currency Rate -> Rates [ratesBase] :: Rates -> Currency [ratesDate] :: Rates -> Day [ratesRates] :: Rates -> Map Currency Rate instance GHC.Generics.Generic Fixer.Types.Rates instance GHC.Classes.Eq Fixer.Types.Rates instance GHC.Show.Show Fixer.Types.Rates instance GHC.Generics.Generic Fixer.Types.Symbols instance GHC.Classes.Ord Fixer.Types.Symbols instance GHC.Classes.Eq Fixer.Types.Symbols instance GHC.Show.Show Fixer.Types.Symbols instance GHC.Generics.Generic Fixer.Types.Currency instance GHC.Enum.Bounded Fixer.Types.Currency instance GHC.Enum.Enum Fixer.Types.Currency instance GHC.Classes.Ord Fixer.Types.Currency instance GHC.Classes.Eq Fixer.Types.Currency instance GHC.Read.Read Fixer.Types.Currency instance GHC.Show.Show Fixer.Types.Currency instance GHC.Generics.Generic Fixer.Types.Rate instance GHC.Classes.Eq Fixer.Types.Rate instance GHC.Show.Show Fixer.Types.Rate instance Data.Validity.Validity Fixer.Types.Rates instance Data.Aeson.Types.FromJSON.FromJSON Fixer.Types.Rates instance Data.Validity.Validity Fixer.Types.Symbols instance Web.Internal.HttpApiData.ToHttpApiData Fixer.Types.Symbols instance Data.Validity.Validity Fixer.Types.Currency instance Web.Internal.HttpApiData.ToHttpApiData Fixer.Types.Currency instance Data.Aeson.Types.FromJSON.FromJSON Fixer.Types.Currency instance Data.Aeson.Types.FromJSON.FromJSONKey Fixer.Types.Currency instance Data.Aeson.Types.ToJSON.ToJSON Fixer.Types.Currency instance Data.Aeson.Types.ToJSON.ToJSONKey Fixer.Types.Currency instance Data.Validity.Validity Fixer.Types.Rate instance Data.Aeson.Types.FromJSON.FromJSON Fixer.Types.Rate instance Data.Aeson.Types.ToJSON.ToJSON Fixer.Types.Rate -- | Caches for the raw API module Fixer.Cache -- | 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. data FixerCache FixerCache :: RateCache -> Set Day -> FixerCache [fCacheRates] :: FixerCache -> RateCache [fCacheDaysWithoutRates] :: FixerCache -> Set Day -- | Insert a given raw response in a FixerCache insertRates :: Day -> Day -> Rates -> FixerCache -> FixerCache -- | The result of looking up rates in a FixerCache data FixerCacheResult NotInCache :: FixerCacheResult -- | Because we requested a date in the future CacheDateNotInPast :: FixerCacheResult -- | Because it was on a weekend or holiday WillNeverExist :: FixerCacheResult InCache :: Rates -> FixerCacheResult -- | Look up rates in cache lookupRates :: Day -> Day -> Currency -> Symbols -> FixerCache -> FixerCacheResult -- | The empty FixerCache emptyFixerCache :: 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. newtype RateCache RateCache :: Map Day (Map Currency (Map Currency Rate)) -> RateCache [unRateCache] :: RateCache -> Map Day (Map Currency (Map Currency Rate)) -- | The empty Cache emptyRateCache :: RateCache -- | Insert a result into the cache. -- -- This is probably the function you want to use, it does all the -- smartness. insertRatesInCache :: Rates -> RateCache -> RateCache -- | Look up multiple rates in a cache. -- -- This function uses smartLookupRateInCache for each requested -- symbol. lookupRatesInCache :: Day -> Currency -> Symbols -> RateCache -> Maybe Rates -- | Insert a rate in a cache, but don't insert it if the from and to -- currencies are the same. smartInsertInCache :: Day -> Currency -> Currency -> Rate -> RateCache -> RateCache -- | 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. smartLookupRateInCache :: Day -> Currency -> Currency -> RateCache -> Maybe Rate -- | The default base currency. Currently this is EUR defaultBaseCurrency :: Currency -- | The symbols to get by default, given a base currency. allSymbolsExcept :: Currency -> Symbols -- | 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. convertToBaseWithRate :: Currency -> Rate -> Rates -> Rates -- | Insert a rate into the cache as-is. -- -- You probably want to be using insertRatesInCache or -- smartInsertInCache instead. rawInsertInCache :: Day -> Currency -> Currency -> Rate -> RateCache -> RateCache -- | Lookup a rate in the cache as-is. -- -- You probably want to be using smartLookupRateInCache instead. rawLookupInCache :: Day -> Currency -> Currency -> RateCache -> Maybe Rate instance GHC.Generics.Generic Fixer.Cache.FixerCache instance GHC.Classes.Eq Fixer.Cache.FixerCache instance GHC.Show.Show Fixer.Cache.FixerCache instance Data.Aeson.Types.ToJSON.ToJSON Fixer.Cache.RateCache instance Data.Aeson.Types.FromJSON.FromJSON Fixer.Cache.RateCache instance GHC.Generics.Generic Fixer.Cache.RateCache instance GHC.Classes.Eq Fixer.Cache.RateCache instance GHC.Show.Show Fixer.Cache.RateCache instance GHC.Generics.Generic Fixer.Cache.FixerCacheResult instance GHC.Classes.Eq Fixer.Cache.FixerCacheResult instance GHC.Show.Show Fixer.Cache.FixerCacheResult instance Data.Validity.Validity Fixer.Cache.FixerCache instance Data.Aeson.Types.FromJSON.FromJSON Fixer.Cache.FixerCache instance Data.Aeson.Types.ToJSON.ToJSON Fixer.Cache.FixerCache instance Data.Validity.Validity Fixer.Cache.RateCache instance Data.Validity.Validity Fixer.Cache.FixerCacheResult -- | The raw API module Fixer.API -- | The full API at api.fixer.io type FixerAPI = GetLatest :<|> GetAtDate -- | Get latest rates -- --
-- /latest?base=<base>&symbols=<symbols> --type GetLatest = "latest" :> (QueryParam "base" Currency :> (QueryParam "symbols" Symbols :> Get '[JSON] Rates)) -- | Get rates on a given date -- --
-- /<date>?base=<base>&symbols=<symbols> --type GetAtDate = Capture "date" Day :> (QueryParam "base" Currency :> (QueryParam "symbols" Symbols :> Get '[JSON] Rates)) -- | A Proxy for FixerAPI fixerAPI :: Proxy FixerAPI -- | The client function for GetLatest getLatest :: Maybe Currency -> Maybe Symbols -> ClientM Rates -- | The client function for GetAtDate getAtDate :: Day -> Maybe Currency -> Maybe Symbols -> ClientM Rates -- | The transparently caching client module Fixer.Client -- | Run a FClient action and figure out the ClientEnv and -- FixerCache arguments automatically. -- -- This is probably the function you want to use autoRunFixerClient :: FClient a -> IO (Either ServantError a) -- | A default configuration for the client: One second of delay between -- calls defaultConfig :: Config -- | Run a FClient action with full control over the inputs. runFixerClient :: FEnv -> ClientEnv -> FClient a -> IO (Either ServantError a) -- | A client function data FClient a -- | 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. getLatest :: Maybe Currency -> Maybe Symbols -> FClient RatesResult -- | Get the rates at a specific date. getAtDate :: Day -> Maybe Currency -> Maybe Symbols -> FClient RatesResult -- | The result of calling the API the local cache data RatesResult -- | because you tried to call the API for a future date DateNotInPast :: RatesResult -- | because the date is on a weekend, for example RateDoesNotExist :: RatesResult RatesFound :: Rates -> RatesResult -- | 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 --withFileCache :: FilePath -> FClient a -> FClient a -- | Read a persistent cache from the given file if that file exists. readCacheFromFileIfExists :: FilePath -> FClient () -- | Flush the currently gathered cache to the given file. flushCacheToFile :: FilePath -> FClient () instance GHC.Generics.Generic Fixer.Client.RatesResult instance GHC.Classes.Eq Fixer.Client.RatesResult instance GHC.Show.Show Fixer.Client.RatesResult instance Control.Monad.IO.Class.MonadIO Fixer.Client.FClient instance Control.Monad.Reader.Class.MonadReader Fixer.Client.FEnv Fixer.Client.FClient instance GHC.Base.Monad Fixer.Client.FClient instance GHC.Base.Applicative Fixer.Client.FClient instance GHC.Base.Functor Fixer.Client.FClient instance GHC.Generics.Generic Fixer.Client.FEnv instance GHC.Generics.Generic Fixer.Client.Config instance GHC.Classes.Eq Fixer.Client.Config instance GHC.Show.Show Fixer.Client.Config instance Data.Validity.Validity Fixer.Client.RatesResult -- | The top-level API for the Haskell Fixer client. -- -- There is an example usage in the README file. module Fixer -- | A client function data FClient a -- | Run a FClient action and figure out the ClientEnv and -- FixerCache arguments automatically. -- -- This is probably the function you want to use autoRunFixerClient :: FClient a -> IO (Either ServantError a) -- | The result of calling the API the local cache data RatesResult -- | because you tried to call the API for a future date DateNotInPast :: RatesResult -- | because the date is on a weekend, for example RateDoesNotExist :: RatesResult RatesFound :: Rates -> RatesResult -- | 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. getLatest :: Maybe Currency -> Maybe Symbols -> FClient RatesResult -- | Get the rates at a specific date. getAtDate :: Day -> Maybe Currency -> Maybe Symbols -> FClient RatesResult -- | 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 --withFileCache :: FilePath -> FClient a -> FClient a -- | A sum-type of the supported currencies on fixer.io data Currency AUD :: Currency BGN :: Currency BRL :: Currency CAD :: Currency CHF :: Currency CNY :: Currency CZK :: Currency DKK :: Currency EUR :: Currency GBP :: Currency HKD :: Currency HRK :: Currency HUF :: Currency IDR :: Currency ILS :: Currency INR :: Currency JPY :: Currency KRW :: Currency MXN :: Currency MYR :: Currency NOK :: Currency NZD :: Currency PHP :: Currency PLN :: Currency RON :: Currency RUB :: Currency SEK :: Currency SGD :: Currency THB :: Currency TRY :: Currency USD :: Currency ZAR :: Currency -- | A nonempty list of Currencys newtype Symbols Symbols :: NonEmpty Currency -> Symbols [unSymbols] :: Symbols -> NonEmpty Currency -- | A positive and non-0 ratio data Rate -- | The raw response of fixer.io data Rates Rates :: Currency -> Day -> Map Currency Rate -> Rates [ratesBase] :: Rates -> Currency [ratesDate] :: Rates -> Day [ratesRates] :: Rates -> Map Currency Rate -- | The identity of mulRate oneRate :: Rate -- | Multiply two rates mulRate :: Rate -> Rate -> Rate -- | Divide one rate by another divRate :: Rate -> Rate -> Rate -- | Convert a rate to a Double. -- -- This may not be a lossless transformation rateToDouble :: Rate -> Double -- | Non-empty (and non-strict) list type. data NonEmpty a :: * -> * (:|) :: a -> [a] -> NonEmpty a -- | The Modified Julian Day is a standard count of days, with zero being -- the day 1858-11-17. data Day :: * -- | Convert from proleptic Gregorian calendar. First argument is year, -- second month number (1-12), third day (1-31). Invalid values will be -- clipped to the correct range, month first, then day. fromGregorian :: Integer -> Int -> Int -> Day