X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FTSN%2FXML%2FWeather.hs;h=f3b60af69c7fb52e013bdab5d5b11d2d6d21b24d;hb=7815ba497d075c63c76418fc2c2b914ebe56b712;hp=3773b312bc021af4a78a97b93c85db4f02e736b4;hpb=014b765322dd54f42c9175772f223b78c6ee8ff6;p=dead%2Fhtsn-import.git diff --git a/src/TSN/XML/Weather.hs b/src/TSN/XML/Weather.hs index 3773b31..f3b60af 100644 --- a/src/TSN/XML/Weather.hs +++ b/src/TSN/XML/Weather.hs @@ -52,7 +52,7 @@ import TSN.Codegen ( import TSN.DbImport ( DbImport(..), ImportResult(..), run_dbmigrate ) import TSN.Picklers ( xp_gamedate ) import TSN.XmlImport ( XmlImport(..) ) -import Xml ( FromXml(..), pickle_unpickle, unpickleable ) +import Xml ( FromXml(..), ToDb(..), pickle_unpickle, unpickleable ) @@ -64,12 +64,14 @@ data WeatherForecastListing = db_weather :: String } deriving (Eq, Show) +-- | The database analogue of a 'WeatherForecastListing' is itself. +instance ToDb WeatherForecastListing where + type Db WeatherForecastListing = WeatherForecastListing + -- | This is needed to define the XmlImport instance for --- 'WeatherForecastListing'; it basically says that the DB --- representation is the same as the XML representation. +-- 'WeatherForecastListing'. -- instance FromXml WeatherForecastListing where - type Db WeatherForecastListing = WeatherForecastListing from_xml = id -- | Allows us to call 'insert_xml' on the XML representation of @@ -110,12 +112,13 @@ data WeatherForecastXml = deriving (Eq, Show) -instance FromXml WeatherForecastXml where +instance ToDb WeatherForecastXml where -- | The database representation of a 'WeatherForecastXml' is a -- 'WeatherForecast'. -- type Db WeatherForecastXml = WeatherForecast +instance FromXml WeatherForecastXml where -- | To convert a 'WeatherForecastXml' into a 'WeatherForecast', we -- replace the 'WeatherLeague' with its name. -- @@ -151,11 +154,12 @@ data Message = deriving (Eq, Show) -instance FromXml Message where +instance ToDb Message where -- | The database representation of 'Message' is 'Weather'. -- type Db Message = Weather +instance FromXml Message where -- | To get a 'Weather' from a 'Message', we drop a bunch of -- unwanted fields. --