From 199404efc365227cc3a94ba7c2c8add8388f6fcc Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Wed, 15 Apr 2015 23:56:48 +0200 Subject: Refactoring so that code is easier to read --- src/AdListener.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/AdListener.hs') diff --git a/src/AdListener.hs b/src/AdListener.hs index 1de56dc..c08efc5 100644 --- a/src/AdListener.hs +++ b/src/AdListener.hs @@ -34,11 +34,12 @@ listenToNewAds config = do eitherResumes <- fetchResumes (C.url config) case eitherResumes of Left error -> - listenError config [] error + showErrorAndListenBack config [] error Right resumes -> let newURLs = map url resumes in do putStrLn "Listening for new ads…" + waitOneMinute listenToNewAdsWithViewedURLs config newURLs listenToNewAdsWithViewedURLs :: Config -> [URL] -> IO () @@ -46,7 +47,7 @@ listenToNewAdsWithViewedURLs config viewedURLs = do eitherResumes <- fetchResumes (C.url config) case eitherResumes of Left error -> - listenError config viewedURLs error + showErrorAndListenBack config viewedURLs error Right resumes -> listenToNewAdsWithResumes config viewedURLs resumes @@ -57,7 +58,7 @@ listenToNewAdsWithResumes config viewedURLs resumes = eitherNewAds <- fetchAds newResumes case eitherNewAds of Left error -> - listenError config viewedURLs error + showErrorAndListenBack config viewedURLs error Right newAds -> do time <- getCurrentFormattedTime @@ -90,8 +91,8 @@ trySendMail config ads = , error ] -listenError :: Config -> [URL] -> Text -> IO () -listenError config viewedURLs error = do +showErrorAndListenBack :: Config -> [URL] -> Text -> IO () +showErrorAndListenBack config viewedURLs error = do T.putStrLn error waitOneMinute listenToNewAdsWithViewedURLs config viewedURLs -- cgit v1.2.3