+{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE ScopedTypeVariables #-}
-- | Handle documents defined by Heartbeat.dtd.
-- System imports.
import Data.Time.Clock ( UTCTime )
import Data.Tuple.Curry ( uncurryN )
+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.DbImport ( ImportResult(..) )
import TSN.Picklers ( xp_time_stamp )
import Xml ( pickle_unpickle, unpickleable )
-- Heartbeat message.
--
data Message =
- Message {
- xml_file_id :: Int,
- heading :: String,
- time_stamp :: UTCTime }
- deriving (Eq, Show)
+ Message
+ Int -- xml_file_id
+ String -- heading
+ UTCTime -- time_stamp
+ deriving (Eq, GHC.Generic, Show)
+
+-- | For 'Generics.to_tuple'.
+--
+instance Generic Message
-- | A (un)pickler that turns a Heartbeat XML file into a 'Message'
(xpElem "time_stamp" xp_time_stamp)
where
from_tuple = uncurryN Message
- to_tuple m = (xml_file_id m,
- heading m,
- time_stamp m)
-- | Verify (and report) the received heartbeat. We return