import TSN.Picklers ( xp_earnings, xp_datetime, xp_time_stamp )
import TSN.XmlImport ( XmlImport(..), XmlImportFk(..) )
import Xml (
+ Child(..),
FromXml(..),
FromXmlFk(..),
ToDb(..),
type Db AutoRacingResultsListingXml = AutoRacingResultsListing
-instance FromXmlFk AutoRacingResultsListingXml where
+instance Child AutoRacingResultsListingXml where
-- | Each 'AutoRacingResultsListingXml' is contained in (i.e. has a
-- foreign key to) a 'AutoRacingResults'.
--
type Parent AutoRacingResultsListingXml = AutoRacingResults
+
+instance FromXmlFk AutoRacingResultsListingXml where
-- | To convert an 'AutoRacingResultsListingXml' to an
-- 'AutoRacingResultsListing', we add the foreign key and copy
-- everything else verbatim.
-- Note the apostrophe to disambiguate it from the
-- AutoRacingResultsListing field.
db_auto_racing_results_id' :: DefaultKey AutoRacingResults,
- db_track_length :: Double,
+ db_track_length :: String, -- ^ Usually a Double, but sometimes a String,
+ -- like \"1.25 miles\".
db_track_length_kph :: Double,
db_laps :: Int,
db_average_speed_mph :: Maybe Double,
--
data AutoRacingResultsRaceInformationXml =
AutoRacingResultsRaceInformationXml {
- xml_track_length :: Double,
+ xml_track_length :: String,
xml_track_length_kph :: Double,
xml_laps :: Int,
xml_average_speed_mph :: Maybe Double,
type Db AutoRacingResultsRaceInformationXml =
AutoRacingResultsRaceInformation
-instance FromXmlFk AutoRacingResultsRaceInformationXml where
+
+instance Child AutoRacingResultsRaceInformationXml where
-- | Each 'AutoRacingResultsRaceInformationXml' is contained in
-- (i.e. has a foreign key to) a 'AutoRacingResults'.
--
type Parent AutoRacingResultsRaceInformationXml = AutoRacingResults
+
+instance FromXmlFk AutoRacingResultsRaceInformationXml where
-- | To convert an 'AutoRacingResultsRaceInformationXml' to an
-- 'AutoRacingResultsRaceInformartion', we add the foreign key and
-- copy everything else verbatim.
xp11Tuple (-- I can't think of another way to get both the
-- TrackLength and its KPH attribute. So we shove them
-- both in a 2-tuple. This should probably be an embedded type!
- xpElem "TrackLength" $ xpPair xpPrim (xpAttr "KPH" xpPrim) )
+ xpElem "TrackLength" $ xpPair xpText (xpAttr "KPH" xpPrim) )
(xpElem "Laps" xpInt)
(xpOption $ xpElem "AverageSpeedMPH" xpPrim)
(xpOption $ xpElem "AverageSpeedKPH" xpPrim)