aboutsummaryrefslogtreecommitdiff
path: root/lib/Web/OpenWeatherMap/API.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Web/OpenWeatherMap/API.hs')
-rw-r--r--lib/Web/OpenWeatherMap/API.hs34
1 files changed, 14 insertions, 20 deletions
diff --git a/lib/Web/OpenWeatherMap/API.hs b/lib/Web/OpenWeatherMap/API.hs
index 757a6be..8a1690e 100644
--- a/lib/Web/OpenWeatherMap/API.hs
+++ b/lib/Web/OpenWeatherMap/API.hs
@@ -2,43 +2,37 @@
Direct API functions.
For API key (a.k.a appid) refer to <http://openweathermap.org/appid>.
-}
-
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
-module Web.OpenWeatherMap.API (
- weatherByName,
- weatherByCoord
-) where
+module Web.OpenWeatherMap.API
+ ( weatherByName
+ , weatherByCoord
+ ) where
import Data.Proxy (Proxy(..))
-import Servant.API ((:>), (:<|>)(..), JSON, Get, QueryParam)
+import Servant.API ((:<|>)(..), (:>), Get, JSON, QueryParam)
import Servant.Client (ClientM, client)
import Web.OpenWeatherMap.Types.CurrentWeather (CurrentWeather)
+type GetCurrentWeather = AppId :> Get '[ JSON] CurrentWeather
-type GetCurrentWeather = AppId :> Get '[JSON] CurrentWeather
type AppId = QueryParam "appid" String
type API
- = "weather" :> QueryParam "q" String :> GetCurrentWeather
- :<|> "weather" :> QueryParam "lat" Double :> QueryParam "lon" Double
- :> GetCurrentWeather
+ = "weather" :> QueryParam "q" String :> GetCurrentWeather :<|> "weather" :> QueryParam "lat" Double :> QueryParam "lon" Double :> GetCurrentWeather
-- | Request current weather in the city.
-weatherByName
- :: Maybe String -- ^ City name, e. g. \"Moscow\" or \"Moscow,ru\".
- -> Maybe String -- ^ API key.
+weatherByName ::
+ Maybe String -- ^ City name, e. g. \"Moscow\" or \"Moscow,ru\".
+ -> Maybe String -- ^ API key.
-> ClientM CurrentWeather
-
-- | Request current weather at the geographic coordinates (in decimal degrees).
-weatherByCoord
- :: Maybe Double -- ^ Latitude, e. g. 55.7522200 for Moscow.
- -> Maybe Double -- ^ Longitude, e. g. 37.6155600 for Moscow.
- -> Maybe String -- ^ API key.
+weatherByCoord ::
+ Maybe Double -- ^ Latitude, e. g. 55.7522200 for Moscow.
+ -> Maybe Double -- ^ Longitude, e. g. 37.6155600 for Moscow.
+ -> Maybe String -- ^ API key.
-> ClientM CurrentWeather
-
weatherByName :<|> weatherByCoord = client (Proxy :: Proxy API)
-