+{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE QuasiQuotes #-}
import Database.Groundhog.TH (
groundhog,
mkPersist )
+import qualified GHC.Generics as GHC ( Generic )
import Test.Tasty ( TestTree, testGroup )
import Test.Tasty.HUnit ( (@?=), testCase )
import Text.XML.HXT.Core (
xpWrap )
-- Local imports.
+import Generics ( Generic(..), to_tuple )
import TSN.Codegen ( tsn_codegen_config )
import TSN.DbImport ( DbImport(..), ImportResult(..), run_dbmigrate )
import TSN.Picklers ( xp_date, xp_time_stamp )
xml_title :: String,
xml_listings :: [AutoRacingDriverListListingXml],
xml_time_stamp :: UTCTime }
- deriving (Eq, Show)
+ deriving (Eq, GHC.Generic, Show)
+
+-- | For 'Generics.to_tuple'.
+--
+instance Generic Message
instance ToDb Message where
xml_nationality :: Maybe String,
xml_car_number :: Int,
xml_car :: String }
- deriving (Eq, Show)
+ deriving (Eq, GHC.Generic, Show)
+-- | For 'Generics.to_tuple'.
+--
+instance Generic AutoRacingDriverListListingXml
instance ToDb AutoRacingDriverListListingXml where
-- | The database analogue of an 'AutoRacingDriverListListingXml' is
(xpElem "Car" xpText)
where
from_tuple = uncurryN AutoRacingDriverListListingXml
- to_tuple m = (xml_driver_id m,
- xml_driver m,
- xml_height m,
- xml_weight m,
- xml_date_of_birth m,
- xml_hometown m,
- xml_nationality m,
- xml_car_number m,
- xml_car m)
-- | Pickler for the top-level 'Message'.
--
(xpElem "time_stamp" xp_time_stamp)
where
from_tuple = uncurryN Message
- to_tuple m = (xml_xml_file_id m,
- xml_heading m,
- xml_category m,
- xml_sport m,
- xml_title m,
- xml_listings m,
- xml_time_stamp m)