diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2020-04-07 16:06:11 +0200 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2020-04-07 16:06:11 +0200 |
commit | 8d54b02d3c4bffbc2c5525e9fc64fac44b77ab96 (patch) | |
tree | 625ebba1e5bedc49fbccaef520f69562a86f768e /lib/Web/OpenWeatherMap/Client.hs | |
parent | d808b4fd3b83cdffe8fc5bd142596b7820ee4a91 (diff) | |
download | openweathermap-8d54b02d3c4bffbc2c5525e9fc64fac44b77ab96.tar.gz |
Reformat with hindent
Diffstat (limited to 'lib/Web/OpenWeatherMap/Client.hs')
-rw-r--r-- | lib/Web/OpenWeatherMap/Client.hs | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/lib/Web/OpenWeatherMap/Client.hs b/lib/Web/OpenWeatherMap/Client.hs index 758ee8f..c7ad7b6 100644 --- a/lib/Web/OpenWeatherMap/Client.hs +++ b/lib/Web/OpenWeatherMap/Client.hs @@ -1,36 +1,42 @@ {-| High-level client functions perfoming requests to OpenWeatherMap API. -} -module Web.OpenWeatherMap.Client ( - Location(..), - getWeather -) where +module Web.OpenWeatherMap.Client + ( Location(..) + , getWeather + ) where + +import Network.HTTP.Client (defaultManagerSettings, newManager) +import Servant.Client + ( BaseUrl(BaseUrl) + , ClientEnv + , ClientError + , ClientM + , Scheme(Http) + , mkClientEnv + , runClientM + ) -import Network.HTTP.Client (newManager, defaultManagerSettings) -import Servant.Client (BaseUrl(BaseUrl), ClientEnv, mkClientEnv, ClientM, Scheme(Http), ClientError, runClientM) - -import Web.OpenWeatherMap.Types.CurrentWeather (CurrentWeather) import qualified Web.OpenWeatherMap.API as API - +import Web.OpenWeatherMap.Types.CurrentWeather (CurrentWeather) -- | Various way to specify location. data Location - = Name String -- ^ City name. - | Coord Double Double -- ^ Geographic coordinates: latitude and longitude. - + = Name String -- ^ City name. + | Coord Double + Double -- ^ Geographic coordinates: latitude and longitude. -- | Make a request to OpenWeatherMap API -- and return current weather in given location. -getWeather - :: String -- ^ API key. +getWeather :: + String -- ^ API key. -> Location -> IO (Either ClientError CurrentWeather) -getWeather appid loc = - defaultEnv >>= runClientM (api loc appid) +getWeather appid loc = defaultEnv >>= runClientM (api loc appid) -api - :: Location - -> String -- ^ API key. +api :: + Location + -> String -- ^ API key. -> ClientM CurrentWeather api (Name city) = API.weatherByName (Just city) . Just api (Coord lat lon) = API.weatherByCoord (Just lat) (Just lon) . Just @@ -44,4 +50,3 @@ defaultEnv = do -- XXX appid is passed in clear text. Oops. baseUrl :: BaseUrl baseUrl = BaseUrl Http "api.openweathermap.org" 80 "/data/2.5" - |