-- 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.4.2 -- | 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
ParseError :: 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.WWOnline
apiUrl :: [Char]
type ApiKey = String
-- | Make config for use with WeatherApi functions
initApi :: ApiKey -> Config
retrieve :: (IsString b, HStream b) => HandleStream b -> [Char] -> IO (Either ApiError b)
get :: (IsString b, HStream b) => HandleStream b -> URI -> IO (Either ApiError b)
-- | This return function witch will actualy retrieve and parse weather
-- from stream
makeQueryFun :: (String -> String) -> (HandleStream String) -> String -> IO ApiResponse
instance FromJSON Weather