improve display + solve all IDE warnings
This commit is contained in:
parent
6772bc97e5
commit
b509dbe492
12
app/Main.hs
12
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
|
||||
@ -67,8 +67,7 @@ apiRequestCity apiKey city =
|
||||
$ 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
|
||||
@ -78,8 +77,7 @@ apiRequestBuilder apiKey day city date =
|
||||
$ setRequestMethod "GET"
|
||||
$ setRequestQueryString query
|
||||
$ setRequestPort 443
|
||||
$ setRequestSecure True
|
||||
$ defaultRequest
|
||||
$ setRequestSecure True defaultRequest
|
||||
where {
|
||||
path
|
||||
| day == Yesterday = "/v1/history.json"
|
||||
|
Loading…
Reference in New Issue
Block a user