diff --git a/app/Main.hs b/app/Main.hs index 02183be..b5d4681 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -31,21 +31,21 @@ main = do let yesterdayRequest = apiRequestBuilder apiKey Yesterday city yesterdayDate yesterdayResponse <- httpLBS yesterdayRequest yesterdayDecoded <- DT.weatherDecode $ getResponseBody yesterdayResponse - print ("Yesterday's temperature: ", DT.getTemperature yesterdayDecoded) + putStr $ "Yesterday's temperature: " ++ show (DT.getTemperature yesterdayDecoded) ++ " celsius\n" --request for today's weather let todayDate = formatDate currentDate let todayRequest = apiRequestBuilder apiKey Today city todayDate todayResponse <- httpLBS todayRequest todayDecoded <- DT.weatherDecode $ getResponseBody todayResponse - print ("Today's temperature: ", DT.getTemperature todayDecoded) + putStr $ "Today's temperature: " ++ show (DT.getTemperature todayDecoded) ++ " celsius\n" --request for tomorrow's weather let tomorrowDate = formatDate $ addDays 1 currentDate let tomorrowRequest = apiRequestBuilder apiKey Tomorrow city tomorrowDate tomorrowResponse <- httpLBS tomorrowRequest tomorrowDecoded <- DT.weatherDecode $ getResponseBody tomorrowResponse - print ("Tomorrow's temperature: ", DT.getTemperature tomorrowDecoded) + putStr $ "Tomorrow's temperature: " ++ show (DT.getTemperature tomorrowDecoded) ++ " celsius\n" generatePlot (DT.getTemperature yesterdayDecoded) (DT.getTemperature todayDecoded) (DT.getTemperature tomorrowDecoded) openPlot @@ -61,25 +61,23 @@ getWeatherKey = do apiRequestCity :: String -> String -> Request -apiRequestCity apiKey city = +apiRequestCity apiKey city = setRequestHost "api.weatherapi.com" $ setRequestPath "/v1/search.json" $ setRequestMethod "GET" $ setRequestQueryString [("key", Just (fromString apiKey)), ("q", Just (fromString city))] $ setRequestPort 443 - $ setRequestSecure True - $ defaultRequest + $ setRequestSecure True defaultRequest apiRequestBuilder :: String -> WhichDay -> String -> String -> Request -apiRequestBuilder apiKey day city date = +apiRequestBuilder apiKey day city date = setRequestHost "api.weatherapi.com" $ setRequestPath path $ setRequestMethod "GET" $ setRequestQueryString query $ setRequestPort 443 - $ setRequestSecure True - $ defaultRequest + $ setRequestSecure True defaultRequest where { path | day == Yesterday = "/v1/history.json"