From: Michael Orlitzky Date: Fri, 2 Jan 2015 22:22:58 +0000 (-0500) Subject: Migrate TSN.XML.Odds to fixed-vector-hetero. X-Git-Tag: 0.2.1~15 X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fhtsn-import.git;a=commitdiff_plain;h=251287a26728178919ca1ce0f7b308df8bd00760 Migrate TSN.XML.Odds to fixed-vector-hetero. --- diff --git a/src/TSN/XML/Odds.hs b/src/TSN/XML/Odds.hs index c3bd6c4..6e47380 100644 --- a/src/TSN/XML/Odds.hs +++ b/src/TSN/XML/Odds.hs @@ -29,6 +29,7 @@ import Control.Applicative ( (<$>) ) import Control.Monad ( forM_, join ) import Data.Time ( UTCTime(..) ) import Data.Tuple.Curry ( uncurryN ) +import qualified Data.Vector.HFixed as H ( HVector, convert ) import Database.Groundhog ( (=.), (==.), @@ -64,7 +65,6 @@ import Text.XML.HXT.Core ( xpWrap ) -- Local imports. -import Generics ( Generic(..), to_tuple ) import TSN.Codegen ( tsn_codegen_config ) import TSN.Database ( insert_or_select ) import TSN.DbImport ( DbImport(..), ImportResult(..), run_dbmigrate ) @@ -128,9 +128,9 @@ data OddsGameCasinoXml = deriving (Eq, GHC.Generic, Show) --- | For 'Generics.to_tuple'. +-- | For 'H.convert'. -- -instance Generic OddsGameCasinoXml +instance H.HVector OddsGameCasinoXml -- | Try to get a 'Double' out of the 'xml_casino_line' which is a @@ -179,9 +179,9 @@ data OddsGameTeamStarterXml = deriving (Eq, GHC.Generic, Show) --- | For 'Generics.to_tuple'. +-- | For 'H.convert'. -- -instance Generic OddsGameTeamStarterXml +instance H.HVector OddsGameTeamStarterXml -- | The XML representation of a \ or \, as @@ -206,9 +206,9 @@ data OddsGameTeamXml = deriving (Eq, GHC.Generic, Show) --- | For 'Generics.to_tuple'. +-- | For 'H.convert'. -- -instance Generic OddsGameTeamXml +instance H.HVector OddsGameTeamXml instance ToDb OddsGameTeamXml where @@ -302,9 +302,9 @@ data OddsGameXml = deriving (Eq, GHC.Generic, Show) --- | For 'Generics.to_tuple'. +-- | For 'H.convert'. -- -instance Generic OddsGameXml +instance H.HVector OddsGameXml -- | Pseudo-field that lets us get the 'OddsGameCasinoXml's out of @@ -442,9 +442,9 @@ data Message = xml_time_stamp :: UTCTime } deriving (Eq, GHC.Generic, Show) --- | For 'Generics.to_tuple'. +-- | For 'H.convert'. -- -instance Generic Message +instance H.HVector Message -- | Pseudo-field that lets us get the 'OddsGame's out of @@ -648,7 +648,7 @@ pickle_game_with_notes = pickle_casino :: PU OddsGameCasinoXml pickle_casino = xpElem "Casino" $ - xpWrap (from_tuple, to_tuple) $ + xpWrap (from_tuple, H.convert) $ xpTriple (xpAttr "ClientID" $ xpOption xpInt) (xpAttr "Name" $ xpOption xpText) @@ -662,7 +662,7 @@ pickle_casino = pickle_home_team :: PU OddsGameTeamXml pickle_home_team = xpElem "HomeTeam" $ - xpWrap (from_tuple, to_tuple) $ + xpWrap (from_tuple, H.convert) $ xp6Tuple (xpElem "HomeTeamID" xpText) (xpElem "HomeRotationNumber" (xpOption xpInt)) @@ -680,7 +680,7 @@ pickle_home_team = -- pickle_starter :: PU OddsGameTeamStarterXml pickle_starter = - xpWrap (from_tuple, to_tuple) $ + xpWrap (from_tuple, H.convert) $ xpPair (xpAttr "ID" xpInt) (xpOption xpText) where from_tuple = uncurry OddsGameTeamStarterXml @@ -704,7 +704,7 @@ pickle_away_starter = xpElem "AStarter" pickle_starter pickle_away_team :: PU OddsGameTeamXml pickle_away_team = xpElem "AwayTeam" $ - xpWrap (from_tuple, to_tuple) $ + xpWrap (from_tuple, H.convert) $ xp6Tuple (xpElem "AwayTeamID" xpText) (xpElem "AwayRotationNumber" (xpOption xpInt)) @@ -734,7 +734,7 @@ pickle_over_under = pickle_game :: PU OddsGameXml pickle_game = xpElem "Game" $ - xpWrap (from_tuple, to_tuple) $ + xpWrap (from_tuple, H.convert) $ xp6Tuple (xpElem "GameID" xpInt) (xpElem "Game_Date" xp_date_padded) @@ -751,7 +751,7 @@ pickle_game = pickle_message :: PU Message pickle_message = xpElem "message" $ - xpWrap (from_tuple, to_tuple) $ + xpWrap (from_tuple, H.convert) $ xp8Tuple (xpElem "XML_File_ID" xpInt) (xpElem "heading" xpText) (xpElem "category" xpText)