improve display + solve all IDE warnings

This commit is contained in:
Szymon Szczubkowski 2024-05-26 19:15:02 +02:00
parent 6772bc97e5
commit b509dbe492

View File

@ -31,21 +31,21 @@ main = do
let yesterdayRequest = apiRequestBuilder apiKey Yesterday city yesterdayDate let yesterdayRequest = apiRequestBuilder apiKey Yesterday city yesterdayDate
yesterdayResponse <- httpLBS yesterdayRequest yesterdayResponse <- httpLBS yesterdayRequest
yesterdayDecoded <- DT.weatherDecode $ getResponseBody yesterdayResponse 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 --request for today's weather
let todayDate = formatDate currentDate let todayDate = formatDate currentDate
let todayRequest = apiRequestBuilder apiKey Today city todayDate let todayRequest = apiRequestBuilder apiKey Today city todayDate
todayResponse <- httpLBS todayRequest todayResponse <- httpLBS todayRequest
todayDecoded <- DT.weatherDecode $ getResponseBody todayResponse 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 --request for tomorrow's weather
let tomorrowDate = formatDate $ addDays 1 currentDate let tomorrowDate = formatDate $ addDays 1 currentDate
let tomorrowRequest = apiRequestBuilder apiKey Tomorrow city tomorrowDate let tomorrowRequest = apiRequestBuilder apiKey Tomorrow city tomorrowDate
tomorrowResponse <- httpLBS tomorrowRequest tomorrowResponse <- httpLBS tomorrowRequest
tomorrowDecoded <- DT.weatherDecode $ getResponseBody tomorrowResponse 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) generatePlot (DT.getTemperature yesterdayDecoded) (DT.getTemperature todayDecoded) (DT.getTemperature tomorrowDecoded)
openPlot openPlot
@ -67,8 +67,7 @@ apiRequestCity apiKey city =
$ setRequestMethod "GET" $ setRequestMethod "GET"
$ setRequestQueryString [("key", Just (fromString apiKey)), ("q", Just (fromString city))] $ setRequestQueryString [("key", Just (fromString apiKey)), ("q", Just (fromString city))]
$ setRequestPort 443 $ setRequestPort 443
$ setRequestSecure True $ setRequestSecure True defaultRequest
$ defaultRequest
apiRequestBuilder :: String -> WhichDay -> String -> String -> Request apiRequestBuilder :: String -> WhichDay -> String -> String -> Request
@ -78,8 +77,7 @@ apiRequestBuilder apiKey day city date =
$ setRequestMethod "GET" $ setRequestMethod "GET"
$ setRequestQueryString query $ setRequestQueryString query
$ setRequestPort 443 $ setRequestPort 443
$ setRequestSecure True $ setRequestSecure True defaultRequest
$ defaultRequest
where { where {
path path
| day == Yesterday = "/v1/history.json" | day == Yesterday = "/v1/history.json"