]> gitweb.michael.orlitzky.com - dead/htsn-import.git/blobdiff - src/TSN/XML/News.hs
Add the FromXmlFk class, like FromXml except it requires an FK (old idea).
[dead/htsn-import.git] / src / TSN / XML / News.hs
index 4a59859cacb770f55fb8472638f02051edbe9dd3..130323cc94544b23081e887b6c551273e71c973d 100644 (file)
@@ -58,7 +58,7 @@ import TSN.Codegen (
 import TSN.DbImport ( DbImport(..), ImportResult(..), run_dbmigrate )
 import TSN.Picklers ( xp_time_stamp )
 import TSN.XmlImport ( XmlImport(..) )
-import Xml ( FromXml(..), pickle_unpickle, unpickleable )
+import Xml ( FromXml(..), ToDb(..), pickle_unpickle, unpickleable )
 
 
 
@@ -68,12 +68,15 @@ data NewsTeam =
   NewsTeam { team_name :: String }
   deriving (Eq, Show)
 
--- | This is needed to define the XmlImport instance for NewsTeam; it
---   basically says that the DB representation is the same as the XML
---   representation.
+
+instance ToDb NewsTeam where
+  -- | The database representaion of a 'NewsTeam' is itself.
+  type Db NewsTeam = NewsTeam
+
+-- | This is needed to define the XmlImport instance for NewsTeam.
 --
 instance FromXml NewsTeam where
-  type Db NewsTeam = NewsTeam
+  -- | How to we get a 'NewsTeam' from itself?
   from_xml = id
 
 -- | Allow us to call 'insert_xml' on the XML representation of
@@ -101,12 +104,14 @@ data NewsLocation =
     country :: String }
   deriving (Eq, Show)
 
--- | This is needed to define the XmlImport instance for NewsLocation; it
---   basically says that the DB representation is the same as the XML
---   representation.
+instance ToDb NewsLocation where
+  -- | The database representation of a 'NewsLocation' is itself.
+  type Db NewsLocation = NewsLocation
+
+-- | This is needed to define the XmlImport instance for NewsLocation.
 --
 instance FromXml NewsLocation where
-  type Db NewsLocation = NewsLocation
+  -- | How to we get a 'NewsLocation' from itself?
   from_xml = id
 
 -- | Allow us to call 'insert_xml' on the XML representation of
@@ -173,12 +178,14 @@ data News =
   deriving (Data, Eq, Show, Typeable)
 
 
+
+instance ToDb Message where
+  type Db Message = News
+
 -- | Convert the XML representation 'Message' to the database
 --   representation 'News'.
 --
 instance FromXml Message where
-  type Db Message = News
-
   -- | We use a record wildcard so GHC doesn't complain that we never
   --   used the field names.
   --