+-- | Pseudo-field that lets us get the 'OddsGame's out of
+-- 'xml_games_with_notes'.
+xml_games :: Message -> [OddsGame]
+xml_games m = map game (xml_games_with_notes m)
+
+instance ToFromXml Odds where
+ type Xml Odds = Message
+ type Container Odds = ()
+
+ -- Use record wildcards to avoid unused field warnings.
+ to_xml (Odds {..}) =
+ Message
+ def
+ def
+ def
+ db_sport
+ db_title
+ db_line_time
+ def
+ def
+
+ -- We don't need the key argument (from_xml_fk) since the XML type
+ -- contains more information in this case.
+ from_xml (Message _ _ _ d e f _ _) =
+ Odds d e f
+
+
+pickle_game_with_notes :: PU OddsGameWithNotes
+pickle_game_with_notes =
+ xpWrap (from_pair, to_pair) $
+ xpPair
+ (xpList $ xpElem "Notes" xpText)
+ pickle_game
+ where
+ from_pair = uncurry OddsGameWithNotes
+ to_pair OddsGameWithNotes{..} = (notes, game)
+