Safe Haskell | None |
---|
WeatherApi
Description
Usage:
required imports
import WeatherApi import WeatherApi.Google
With handler in case server will alow you to make few requests with one connection
>>>
let h = mkWeatherHandler $ initApi "en" "utf-8"
>>>
getWeather h "moscow"
Right (Weather { tempF = 75.0 , tempC = 24.0 , humidity = "Humidity: 25%" , windCondition = "Wind: S at 16 mph" , condition = "Clear" })
Simple case
>>>
getWeather' (initApi "en" "utf-8") "moscow"
Right (Weather { tempF = 75.0 , tempC = 24.0 , humidity = "Humidity: 25%" , windCondition = "Wind: S at 16 mph" , condition = "Clear" })
- data WeatherApiHandler = WeatherApiHandler {}
- data Config = Config {
- apiHost :: String
- apiPort :: Int
- queryFun :: HandleStream String -> String -> IO ApiResponse
- data Weather = Weather {}
- data ApiError
- type ApiResponse = Either ApiError Weather
- getWeather :: WeatherApiHandler -> String -> IO ApiResponse
- getWeather' :: Config -> String -> IO ApiResponse
- mkWeatherHandler :: Config -> WeatherApiHandler
- isHandlerAlive :: WeatherApiHandler -> IO Bool
- closeHandler :: WeatherApiHandler -> IO ()
Documentation
data WeatherApiHandler Source
Constructors
WeatherApiHandler | |
Constructors
Weather | |
Constructors
NotFoundError String | |
NetworkError String | |
ParseError String |
type ApiResponse = Either ApiError WeatherSource
getWeather :: WeatherApiHandler -> String -> IO ApiResponseSource
Retrieve weather using existing handler
getWeather' :: Config -> String -> IO ApiResponseSource
Retrieve weather using just config It's usefull when you don't need one connection for few requests
closeHandler :: WeatherApiHandler -> IO ()Source