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 (
(=.),
(==.),
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 )
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
deriving (Eq, GHC.Generic, Show)
--- | For 'Generics.to_tuple'.
+-- | For 'H.convert'.
--
-instance Generic OddsGameTeamStarterXml
+instance H.HVector OddsGameTeamStarterXml
-- | The XML representation of a \<HomeTeam\> or \<AwayTeam\>, as
deriving (Eq, GHC.Generic, Show)
--- | For 'Generics.to_tuple'.
+-- | For 'H.convert'.
--
-instance Generic OddsGameTeamXml
+instance H.HVector OddsGameTeamXml
instance ToDb OddsGameTeamXml where
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
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
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)
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))
--
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
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))
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)
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)