From 6772bc97e5f1868b4653ceb77f38d164f0521436 Mon Sep 17 00:00:00 2001 From: Szymon Szczubkowski Date: Sun, 26 May 2024 19:08:56 +0200 Subject: [PATCH] fix wrong numeric types --- app/Main.hs | 6 +++--- app/Plot.hs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index d4c1fd8..02183be 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -15,9 +15,6 @@ main :: IO () main = do apiKey <- getWeatherKey - generatePlot 20 35 25 --example - openPlot - putStrLn "Enter a city name: " city <- getLine @@ -50,6 +47,9 @@ main = do tomorrowDecoded <- DT.weatherDecode $ getResponseBody tomorrowResponse print ("Tomorrow's temperature: ", DT.getTemperature tomorrowDecoded) + generatePlot (DT.getTemperature yesterdayDecoded) (DT.getTemperature todayDecoded) (DT.getTemperature tomorrowDecoded) + openPlot + --apiKey is stored in an env variable, not something that should be pushed onto git getWeatherKey :: IO String diff --git a/app/Plot.hs b/app/Plot.hs index 9ea4f46..7d0b1f3 100644 --- a/app/Plot.hs +++ b/app/Plot.hs @@ -4,11 +4,11 @@ import Graphics.Rendering.Chart.Backend.Diagrams import System.Process (callCommand) -formatData :: Double -> Double -> Double -> [(Int, Double)] +formatData :: Float -> Float -> Float -> [(Int, Float)] formatData yday tday tmrw = [(0, yday), (1, tday), (2, tmrw)] -generatePlot :: Double -> Double -> Double -> IO () +generatePlot :: Float -> Float -> Float -> IO () generatePlot yday tday tmrw = toFile def "plot/weather.svg" $ do layout_title .= "Yesterday, Today, and Tomorrow's Temperatures" layout_margin .= 30