-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Weather api implemented in haskell -- -- This library implement generic api for retrieving weather by http, and -- has google weather api as example. @package weather-api @version 0.2.0 -- | 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"
-- })
--
module WeatherApi
data WeatherApiHandler
WeatherApiHandler :: IO (HandleStream String) -> Config -> WeatherApiHandler
stream :: WeatherApiHandler -> IO (HandleStream String)
config :: WeatherApiHandler -> Config
data Config
Config :: String -> Int -> (HandleStream String -> String -> IO (ApiResponse)) -> Config
apiHost :: Config -> String
apiPort :: Config -> Int
queryFun :: Config -> HandleStream String -> String -> IO (ApiResponse)
data Weather
Weather :: Double -> Double -> String -> String -> String -> Weather
tempF :: Weather -> Double
tempC :: Weather -> Double
humidity :: Weather -> String
windCondition :: Weather -> String
condition :: Weather -> String
data ApiError
NotFoundError :: String -> ApiError
NetworkError :: String -> ApiError
type ApiResponse = Either ApiError Weather
-- | Retrieve weather using existing handler
getWeather :: WeatherApiHandler -> String -> IO ApiResponse
-- | Retrieve weather using just config It's usefull when you don't need
-- one connection for few requests
getWeather' :: Config -> String -> IO ApiResponse
mkWeatherHandler :: Config -> WeatherApiHandler
isHandlerAlive :: WeatherApiHandler -> IO Bool
closeHandler :: WeatherApiHandler -> IO ()
instance Eq Weather
instance Show Weather
instance Show ApiError
module WeatherApi.Google
-- | Make config for use with WeatherApi functions
initApi :: Lang -> Enc -> Config