From: Michael Orlitzky Date: Thu, 2 Jan 2014 17:00:42 +0000 (-0500) Subject: Fix hlint suggestions. X-Git-Tag: 0.0.1~119 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=6883632cfac0e3ee7ad6781300555dbf40d98b40;p=dead%2Fhtsn-import.git Fix hlint suggestions. --- diff --git a/src/Main.hs b/src/Main.hs index e8c1356..d66f704 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -211,7 +211,7 @@ main = do report_info $ "Removed processed file " ++ path ++ "." -- | Try to remove @path@ and potentially try again. - kill try_again path = do + kill try_again path = (remove_and_report path) `catchIOError` exception_handler where -- | A wrapper around threadDelay which takes seconds instead of @@ -228,7 +228,7 @@ main = do report_error (show e) report_error $ "Failed to remove imported file " ++ path ++ "." if try_again then do - report_info $ "Waiting 5 seconds to attempt removal again..." + report_info "Waiting 5 seconds to attempt removal again..." thread_sleep 5 kill False path else diff --git a/src/TSN/XML/News.hs b/src/TSN/XML/News.hs index 26ca8c0..565c7a5 100644 --- a/src/TSN/XML/News.hs +++ b/src/TSN/XML/News.hs @@ -270,8 +270,8 @@ pickle_message = (xpElem "category" xpText) (xpElem "sport" xpText) (xpElem "url" xpText) - (xpList $ pickle_news_team) - (xpList $ pickle_location) + (xpList pickle_news_team) + (xpList pickle_location) (xpElem "SMS" xpText) (xpOption (xpElem "Editor" xpText)) (xpElem "text" xpText) @@ -297,7 +297,7 @@ pickle_message = pickle_continue = xpWrap (to_string, from_string) $ xpElem "continue" $ - (xpList $ xpElem "P" xpText) + xpList (xpElem "P" xpText) where from_string :: String -> [String] from_string = split "\n" @@ -339,15 +339,13 @@ news_tests = testGroup "News tests" [ test_news_fields_have_correct_names, - test_pickle_of_unpickle_is_identity1, - test_pickle_of_unpickle_is_identity2, - test_unpickle_succeeds1, - test_unpickle_succeeds2 ] + test_pickle_of_unpickle_is_identity, + test_unpickle_succeeds ] test_news_fields_have_correct_names :: TestTree test_news_fields_have_correct_names = - testCase "news fields get correct database names" $ do + testCase "news fields get correct database names" $ mapM_ check (zip actual expected) where -- This is cool, it uses the (derived) Data instance of @@ -368,34 +366,28 @@ test_news_fields_have_correct_names = -- | Warning, succeess of this test does not mean that unpickling -- succeeded. -test_pickle_of_unpickle_is_identity1 :: TestTree -test_pickle_of_unpickle_is_identity1 = - testCase "pickle composed with unpickle is the identity" $ do - let path = "test/xml/newsxml.xml" - (expected :: [MessageXml], actual) <- pickle_unpickle "message" path - actual @?= expected - --- | Repeat of 'test_pickle_of_unpickle_is_identity1' with a different --- XML file. -test_pickle_of_unpickle_is_identity2 :: TestTree -test_pickle_of_unpickle_is_identity2 = - testCase "pickle composed with unpickle is the identity (with Editor)" $ do - let path = "test/xml/newsxml-with-editor.xml" - (expected :: [MessageXml], actual) <- pickle_unpickle "message" path - actual @?= expected - -test_unpickle_succeeds1 :: TestTree -test_unpickle_succeeds1 = - testCase "unpickling succeeds" $ do - let path = "test/xml/newsxml.xml" - actual <- unpickleable path pickle_message - let expected = True - actual @?= expected - -test_unpickle_succeeds2 :: TestTree -test_unpickle_succeeds2 = - testCase "unpickling succeeds (with Editor)" $ do - let path = "test/xml/newsxml-with-editor.xml" - actual <- unpickleable path pickle_message - let expected = True - actual @?= expected +test_pickle_of_unpickle_is_identity :: TestTree +test_pickle_of_unpickle_is_identity = testGroup "pickle-unpickle tests" + [ check "pickle composed with unpickle is the identity" + "test/xml/newsxml.xml", + + check "pickle composed with unpickle is the identity (with Editor)" + "test/xml/newsxml-with-editor.xml" ] + where + check desc path = testCase desc $ do + (expected :: [MessageXml], actual) <- pickle_unpickle "message" path + actual @?= expected + + +test_unpickle_succeeds :: TestTree +test_unpickle_succeeds = testGroup "unpickle tests" + [ check "unpickling succeeds" + "test/xml/newsxml.xml", + + check "unpickling succeeds (with Editor)" + "test/xml/newsxml-with-editor.xml" ] + where + check desc path = testCase desc $ do + actual <- unpickleable path pickle_message + let expected = True + actual @?= expected diff --git a/src/TSN/XML/Odds.hs b/src/TSN/XML/Odds.hs index 9b35736..7143c45 100644 --- a/src/TSN/XML/Odds.hs +++ b/src/TSN/XML/Odds.hs @@ -250,9 +250,9 @@ pickle_message = (xpElem "Title" xpText) (xpElem "Line_Time" xpText) pickle_notes - (xpList $ pickle_game) + (xpList pickle_game) pickle_notes - (xpList $ pickle_game) + (xpList pickle_game) (xpElem "time_stamp" xpText) where from_tuple = uncurryN MessageXml @@ -271,7 +271,7 @@ pickle_message = pickle_notes :: PU String pickle_notes = xpWrap (to_string, from_string) $ - (xpList $ xpElem "Notes" xpText) + xpList (xpElem "Notes" xpText) where from_string :: String -> [String] from_string = split "\n" diff --git a/src/Xml.hs b/src/Xml.hs index 2f68dd0..e98e4b1 100644 --- a/src/Xml.hs +++ b/src/Xml.hs @@ -106,7 +106,7 @@ pickle_unpickle :: XmlPickler a pickle_unpickle root_element filepath = do -- We need to check only the root message element since -- readDocument produces a bunch of other junk. - expected <- runX $ arr_getobj + expected <- runX arr_getobj actual <- runX $ arr_getobj >>> xpickleVal xpickle