]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blobdiff - src/TSN/XML/News.hs
Make the text of a news URL optional.
[dead/htsn-import.git] / src / TSN / XML / News.hs
index f799a5238b1fe3013b764153d3571149881f0cb4..49ff8b7d655ff1c41cc2ef1423b79948e4b8731c 100644 (file)
@@ -3,7 +3,6 @@
 {-# LANGUAGE GADTs #-}
 {-# LANGUAGE QuasiQuotes #-}
 {-# LANGUAGE RecordWildCards #-}
-{-# LANGUAGE ScopedTypeVariables #-}
 {-# LANGUAGE StandaloneDeriving #-}
 {-# LANGUAGE TemplateHaskell #-}
 {-# LANGUAGE TypeFamilies #-}
@@ -12,8 +11,8 @@
 --   root element \<message\> that contains an entire news item.
 --
 module TSN.XML.News (
-  Message,
-  news_tests )
+  news_tests,
+  pickle_message )
 where
 
 import Data.Data ( Data, constrFields, dataTypeConstrs, dataTypeOf )
@@ -32,7 +31,6 @@ import Test.Tasty ( TestTree, testGroup )
 import Test.Tasty.HUnit ( (@?=), testCase )
 import Text.XML.HXT.Core (
   PU,
-  XmlPickler(..),
   xp13Tuple,
   xpAttr,
   xpElem,
@@ -41,6 +39,7 @@ import Text.XML.HXT.Core (
   xpOption,
   xpPair,
   xpText,
+  xpText0,
   xpTriple,
   xpWrap )
 
@@ -238,8 +237,6 @@ pickle_news_team =
     from_string :: String -> NewsTeam
     from_string = NewsTeam
 
-instance XmlPickler NewsTeam where
-  xpickle = pickle_news_team
 
 pickle_msg_id :: PU MsgId
 pickle_msg_id =
@@ -250,8 +247,6 @@ pickle_msg_id =
     from_tuple = uncurryN MsgId
     to_tuple m = (db_msg_id m, db_event_id m)
 
-instance XmlPickler MsgId where
-  xpickle = pickle_msg_id
 
 pickle_location :: PU NewsLocation
 pickle_location =
@@ -265,8 +260,6 @@ pickle_location =
       uncurryN NewsLocation
     to_tuple l = (city l, state l, country l)
 
-instance XmlPickler NewsLocation where
-  xpickle = pickle_location
 
 
 pickle_message :: PU Message
@@ -278,7 +271,7 @@ pickle_message =
               pickle_msg_id
               (xpElem "category" xpText)
               (xpElem "sport" xpText)
-              (xpElem "url" xpText)
+              (xpElem "url" xpText0)
               (xpList pickle_news_team)
               (xpList pickle_location)
               (xpElem "SMS" xpText)
@@ -315,9 +308,6 @@ pickle_message =
         to_string :: [String] -> String
         to_string = join "\n"
 
-instance XmlPickler Message where
-  xpickle = pickle_message
-
 
 
 -- * Tasty Tests
@@ -362,7 +352,7 @@ test_pickle_of_unpickle_is_identity = testGroup "pickle-unpickle tests"
           "test/xml/newsxml-with-editor.xml" ]
   where
     check desc path = testCase desc $ do
-      (expected :: [Message], actual) <- pickle_unpickle "message" path
+      (expected, actual) <- pickle_unpickle pickle_message path
       actual @?= expected