From: Michael Orlitzky Date: Fri, 2 Jan 2015 21:18:44 +0000 (-0500) Subject: Migrate TSN.XML.AutoRacingResults to fixed-vector-hetero. X-Git-Tag: 0.2.1~24 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=c04989ba059270be9fa40ed3ecf156c92398b550;p=dead%2Fhtsn-import.git Migrate TSN.XML.AutoRacingResults to fixed-vector-hetero. --- diff --git a/src/TSN/XML/AutoRacingResults.hs b/src/TSN/XML/AutoRacingResults.hs index e2bb7e7..e540e06 100644 --- a/src/TSN/XML/AutoRacingResults.hs +++ b/src/TSN/XML/AutoRacingResults.hs @@ -1,4 +1,3 @@ - {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleInstances #-} @@ -30,6 +29,7 @@ import Data.Maybe ( fromMaybe ) import Data.Time ( UTCTime(..) ) import Data.Tuple.Curry ( uncurryN ) import Data.Typeable ( Typeable ) +import qualified Data.Vector.HFixed as H ( HVector, cons, convert ) import Database.Groundhog ( countAll, deleteAll, @@ -62,7 +62,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 ( @@ -134,9 +133,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 @@ -197,9 +196,9 @@ data AutoRacingResultsListing = _db_earnings :: Maybe Int } deriving ( GHC.Generic ) --- | For 'Generics.prepend'. +-- | For 'H.convert' and 'H.cons'. -- -instance Generic AutoRacingResultsListing +instance H.HVector AutoRacingResultsListing -- | XML representation of a \ contained within a -- \. The leading underscores prevent unused field @@ -222,9 +221,9 @@ data AutoRacingResultsListingXml = _xml_earnings :: Maybe Int } deriving (Eq, GHC.Generic, Show) --- | For 'Generics.to_tuple'. +-- | For 'H.convert'. -- -instance Generic AutoRacingResultsListingXml +instance H.HVector AutoRacingResultsListingXml instance ToDb AutoRacingResultsListingXml where -- | The database analogue of an 'AutoRacingResultsListingXml' is @@ -245,7 +244,7 @@ instance FromXmlFk AutoRacingResultsListingXml where -- 'AutoRacingResultsListing', we add the foreign key and copy -- everything else verbatim. -- - from_xml_fk = prepend + from_xml_fk = H.cons -- | This allows us to insert the XML representation @@ -460,7 +459,7 @@ mkPersist tsn_codegen_config [groundhog| pickle_listing :: PU AutoRacingResultsListingXml pickle_listing = xpElem "Listing" $ - xpWrap (from_tuple, to_tuple) $ + xpWrap (from_tuple, H.convert) $ xp13Tuple (xpElem "FinishPosition" xpInt) (xpElem "StartingPosition" xpInt) (xpElem "CarNumber" xpInt) @@ -483,7 +482,7 @@ pickle_listing = pickle_message :: PU Message pickle_message = xpElem "message" $ - xpWrap (from_tuple, to_tuple) $ + xpWrap (from_tuple, H.convert) $ xp13Tuple (xpElem "XML_File_ID" xpInt) (xpElem "heading" xpText) (xpElem "category" xpText)