From cb3f7338fe719b5a4689e1ace3abd8431a31ea74 Mon Sep 17 00:00:00 2001 From: John Millikin Date: Mon, 30 Jul 2012 20:44:00 -0700 Subject: [PATCH] Add derived 'Data' instances to types. --- lib/Data/XML/Types.hs | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/Data/XML/Types.hs b/lib/Data/XML/Types.hs index c96fe2e..32f0d04 100644 --- a/lib/Data/XML/Types.hs +++ b/lib/Data/XML/Types.hs @@ -69,11 +69,12 @@ module Data.XML.Types ) where import Control.Monad ((>=>)) +import Data.Data (Data) +import Data.Function (on) import Data.Maybe (isJust) +import Data.String (IsString, fromString) import Data.Text (Text) import qualified Data.Text as T -import Data.String (IsString, fromString) -import Data.Function (on) import Data.Typeable (Typeable) data Document = Document @@ -81,44 +82,44 @@ data Document = Document , documentRoot :: Element , documentEpilogue :: [Miscellaneous] } - deriving (Show, Eq, Ord, Typeable) + deriving (Data, Eq, Ord, Show, Typeable) data Prologue = Prologue { prologueBefore :: [Miscellaneous] , prologueDoctype :: Maybe Doctype , prologueAfter :: [Miscellaneous] } - deriving (Show, Eq, Ord, Typeable) + deriving (Data, Eq, Ord, Show, Typeable) data Instruction = Instruction { instructionTarget :: Text , instructionData :: Text } - deriving (Show, Eq, Ord, Typeable) + deriving (Data, Eq, Ord, Show, Typeable) data Miscellaneous = MiscInstruction Instruction | MiscComment Text - deriving (Show, Eq, Ord, Typeable) + deriving (Data, Eq, Ord, Show, Typeable) data Node = NodeElement Element | NodeInstruction Instruction | NodeContent Content | NodeComment Text - deriving (Show, Eq, Ord, Typeable) + deriving (Data, Eq, Ord, Show, Typeable) data Element = Element { elementName :: Name , elementAttributes :: [(Name, [Content])] , elementNodes :: [Node] } - deriving (Show, Eq, Ord, Typeable) + deriving (Data, Eq, Ord, Show, Typeable) data Content = ContentText Text | ContentEntity Text -- ^ For pass-through parsing - deriving (Show, Eq, Ord, Typeable) + deriving (Data, Eq, Ord, Show, Typeable) -- | A fully qualified name. -- @@ -140,7 +141,7 @@ data Name = Name , nameNamespace :: Maybe Text , namePrefix :: Maybe Text } - deriving (Show, Typeable) + deriving (Data, Show, Typeable) instance Eq Name where (==) = (==) `on` (\x -> (nameNamespace x, nameLocalName x)) @@ -165,12 +166,12 @@ data Doctype = Doctype { doctypeName :: Text , doctypeID :: Maybe ExternalID } - deriving (Show, Eq, Ord, Typeable) + deriving (Data, Eq, Ord, Show, Typeable) data ExternalID = SystemID Text | PublicID Text Text - deriving (Show, Eq, Ord, Typeable) + deriving (Data, Eq, Ord, Show, Typeable) -- | Some XML processing tools are incremental, and work in terms of events -- rather than node trees. The 'Event' type allows a document to be fully @@ -195,7 +196,7 @@ data Event | EventContent Content | EventComment Text | EventCDATA Text - deriving (Show, Eq, Ord, Typeable) + deriving (Data, Eq, Ord, Show, Typeable) isElement :: Node -> [Element] isElement (NodeElement e) = [e] -- 2.34.2