From: Michael Orlitzky Date: Fri, 2 Jan 2015 17:55:57 +0000 (-0500) Subject: Use Generics.prepend in TSN.XML.AutoRacingDriverList. X-Git-Tag: 0.2.1~32 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=1f04fd8786215141dad63099dc6f48d17b7ac96c;p=dead%2Fhtsn-import.git Use Generics.prepend in TSN.XML.AutoRacingDriverList. --- diff --git a/src/TSN/XML/AutoRacingDriverList.hs b/src/TSN/XML/AutoRacingDriverList.hs index b1a611e..9d9e090 100644 --- a/src/TSN/XML/AutoRacingDriverList.hs +++ b/src/TSN/XML/AutoRacingDriverList.hs @@ -52,7 +52,7 @@ import Text.XML.HXT.Core ( xpWrap ) -- Local imports. -import Generics ( Generic(..), to_tuple ) +import Generics ( Generic(..), prepend, to_tuple ) import TSN.Codegen ( tsn_codegen_config ) import TSN.DbImport ( DbImport(..), ImportResult(..), run_dbmigrate ) import TSN.Picklers ( xp_date, xp_time_stamp ) @@ -157,6 +157,12 @@ data AutoRacingDriverListListing = db_nationality :: Maybe String, db_car_number :: Int, db_car :: String } + deriving ( GHC.Generic ) + +-- | For 'Generics.prepend'. +-- +instance Generic AutoRacingDriverListListing + -- | XML representation of a \ contained within a -- \. @@ -197,18 +203,8 @@ instance FromXmlFk AutoRacingDriverListListingXml where -- 'AutoRacingDriverListListing', we add the foreign key and copy -- everything else verbatim. -- - from_xml_fk fk AutoRacingDriverListListingXml{..} = - AutoRacingDriverListListing { - db_auto_racing_driver_lists_id = fk, - db_driver_id = xml_driver_id, - db_driver = xml_driver, - db_height = xml_height, - db_weight = xml_weight, - db_date_of_birth = xml_date_of_birth, - db_hometown = xml_hometown, - db_nationality = xml_nationality, - db_car_number = xml_car_number, - db_car = xml_car } + from_xml_fk = prepend + -- | This allows us to insert the XML representation