From: Michael Orlitzky Date: Fri, 2 Jan 2015 21:18:18 +0000 (-0500) Subject: Migrate TSN.XML.AutoRacingDriverList to fixed-vector-hetero. X-Git-Tag: 0.2.1~25 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=99cb78224987bd773f5c008df81302e07ff31e25;p=dead%2Fhtsn-import.git Migrate TSN.XML.AutoRacingDriverList to fixed-vector-hetero. --- diff --git a/src/TSN/XML/AutoRacingDriverList.hs b/src/TSN/XML/AutoRacingDriverList.hs index af4fb85..453986e 100644 --- a/src/TSN/XML/AutoRacingDriverList.hs +++ b/src/TSN/XML/AutoRacingDriverList.hs @@ -25,6 +25,7 @@ where import Control.Monad ( forM_ ) import Data.Time ( UTCTime(..) ) import Data.Tuple.Curry ( uncurryN ) +import qualified Data.Vector.HFixed as H ( HVector, cons, convert ) import Database.Groundhog ( countAll, deleteAll, @@ -52,7 +53,6 @@ import Text.XML.HXT.Core ( xpWrap ) -- Local imports. -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 ) @@ -106,9 +106,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 instance ToDb Message where @@ -160,9 +160,9 @@ data AutoRacingDriverListListing = _db_car :: String } deriving ( GHC.Generic ) --- | For 'Generics.prepend'. +-- | For 'H.convert'. -- -instance Generic AutoRacingDriverListListing +instance H.HVector AutoRacingDriverListListing -- | XML representation of a \ contained within a @@ -181,9 +181,9 @@ data AutoRacingDriverListListingXml = _xml_car :: String } deriving (Eq, GHC.Generic, Show) --- | For 'Generics.to_tuple'. +-- | For 'H.convert' and 'H.cons'. -- -instance Generic AutoRacingDriverListListingXml +instance H.HVector AutoRacingDriverListListingXml instance ToDb AutoRacingDriverListListingXml where -- | The database analogue of an 'AutoRacingDriverListListingXml' is @@ -204,7 +204,7 @@ instance FromXmlFk AutoRacingDriverListListingXml where -- 'AutoRacingDriverListListing', we add the foreign key and copy -- everything else verbatim. -- - from_xml_fk = prepend + from_xml_fk = H.cons @@ -267,7 +267,7 @@ mkPersist tsn_codegen_config [groundhog| pickle_listing :: PU AutoRacingDriverListListingXml pickle_listing = xpElem "Listing" $ - xpWrap (from_tuple, to_tuple) $ + xpWrap (from_tuple, H.convert) $ xp9Tuple (xpElem "DriverID" xpInt) (xpElem "Driver" xpText) (xpElem "Height" $ xpOption xpText) @@ -285,7 +285,7 @@ pickle_listing = pickle_message :: PU Message pickle_message = xpElem "message" $ - xpWrap (from_tuple, to_tuple) $ + xpWrap (from_tuple, H.convert) $ xp7Tuple (xpElem "XML_File_ID" xpInt) (xpElem "heading" xpText) (xpElem "category" xpText)