From 79cba02a6f520256991b345e9dffdaedf68ddde0 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 1 Jan 2014 20:02:24 -0500 Subject: [PATCH] Remove the XmlPickler instance for Bool. Use xpPrim instead of the (removed) xpickle for Bools. Replace xpPrim with xpInt where possible. --- src/TSN/Picklers.hs | 11 ----------- src/TSN/XML/Injuries.hs | 5 +++-- src/TSN/XML/InjuriesDetail.hs | 7 ++++--- src/TSN/XML/News.hs | 9 ++++----- 4 files changed, 11 insertions(+), 21 deletions(-) diff --git a/src/TSN/Picklers.hs b/src/TSN/Picklers.hs index c430b8d..16a25ef 100644 --- a/src/TSN/Picklers.hs +++ b/src/TSN/Picklers.hs @@ -12,21 +12,10 @@ import System.Locale ( defaultTimeLocale ) import Text.Printf ( printf ) import Text.Read ( readMaybe ) import Text.XML.HXT.Arrow.Pickle ( - XmlPickler(..), xpText, xpWrapMaybe ) import Text.XML.HXT.Arrow.Pickle.Xml ( PU ) -instance XmlPickler Bool where - xpickle = - (to_bool, from_bool) `xpWrapMaybe` xpText - where - to_bool :: String -> Maybe Bool - to_bool = readMaybe - - from_bool :: Bool -> String - from_bool = show - -- | (Un)pickle a UTCTime without the time portion. -- diff --git a/src/TSN/XML/Injuries.hs b/src/TSN/XML/Injuries.hs index 92bf4e2..53e2419 100644 --- a/src/TSN/XML/Injuries.hs +++ b/src/TSN/XML/Injuries.hs @@ -33,6 +33,7 @@ import Text.XML.HXT.Core ( xp4Tuple, xp6Tuple, xpElem, + xpInt, xpList, xpPrim, xpText, @@ -73,7 +74,7 @@ pickle_listing = xpElem "listing" $ xpWrap (from_tuple, to_tuple) $ xp4Tuple (xpElem "team" xpText) - (xpElem "teamno" xpPrim) + (xpElem "teamno" xpInt) (xpElem "injuries" xpText) (xpElem "updated" xpPrim) where @@ -88,7 +89,7 @@ pickle_message :: PU Message pickle_message = xpElem "message" $ xpWrap (from_tuple, to_tuple) $ - xp6Tuple (xpElem "XML_File_ID" xpPrim) + xp6Tuple (xpElem "XML_File_ID" xpInt) (xpElem "heading" xpText) (xpElem "category" xpText) (xpElem "sport" xpText) diff --git a/src/TSN/XML/InjuriesDetail.hs b/src/TSN/XML/InjuriesDetail.hs index cb3afea..81b915d 100644 --- a/src/TSN/XML/InjuriesDetail.hs +++ b/src/TSN/XML/InjuriesDetail.hs @@ -40,6 +40,7 @@ import Text.XML.HXT.Core ( xp6Tuple, xp10Tuple, xpElem, + xpInt, xpList, xpPrim, xpText, @@ -95,14 +96,14 @@ pickle_player_listing = xpElem "PlayerListing" $ xpWrap (from_tuple, to_tuple) $ xp10Tuple (xpElem "TeamID" xp_team_id) - (xpElem "PlayerID" xpPrim) + (xpElem "PlayerID" xpInt) (xpElem "Date" xp_date) (xpElem "Pos" xpText) (xpElem "Name" xpText) (xpElem "Injury" xpText) (xpElem "Status" xpText) (xpElem "Fantasy" xpText0) - (xpElem "Injured" xpickle) + (xpElem "Injured" xpPrim) (xpElem "Type" xpText) where from_tuple = uncurryN PlayerListing @@ -139,7 +140,7 @@ pickle_message :: PU Message pickle_message = xpElem "message" $ xpWrap (from_tuple, to_tuple) $ - xp6Tuple (xpElem "XML_File_ID" xpPrim) + xp6Tuple (xpElem "XML_File_ID" xpInt) (xpElem "heading" xpText) (xpElem "category" xpText) (xpElem "sport" xpText) diff --git a/src/TSN/XML/News.hs b/src/TSN/XML/News.hs index aa1a01c..31587a3 100644 --- a/src/TSN/XML/News.hs +++ b/src/TSN/XML/News.hs @@ -39,18 +39,17 @@ import Text.XML.HXT.Core ( xp12Tuple, xpAttr, xpElem, + xpInt, xpList, xpOption, xpPair, - xpPrim, xpText, xpTriple, xpWrap ) import TSN.Codegen ( tsn_codegen_config, - tsn_db_field_namer -- Used in a test. - ) + tsn_db_field_namer ) -- Used in a test import TSN.DbImport ( DbImport(..), ImportResult(..) ) import Xml ( ToFromXml(..), pickle_unpickle ) @@ -233,7 +232,7 @@ pickle_msg_id :: PU MsgId pickle_msg_id = xpElem "msg_id" $ xpWrap (from_tuple, to_tuple) $ - xpPair xpPrim (xpAttr "EventId" (xpOption xpPrim)) + xpPair xpInt (xpAttr "EventId" (xpOption xpInt)) where from_tuple = uncurryN MsgId to_tuple m = (db_msg_id m, db_event_id m) @@ -261,7 +260,7 @@ pickle_message :: PU MessageXml pickle_message = xpElem "message" $ xpWrap (from_tuple, to_tuple) $ - xp12Tuple (xpElem "XML_File_ID" xpPrim) + xp12Tuple (xpElem "XML_File_ID" xpInt) (xpElem "heading" xpText) pickle_msg_id (xpElem "category" xpText) -- 2.43.2