~singpolyma/xml-types-haskell

cb3f7338fe719b5a4689e1ace3abd8431a31ea74 — John Millikin 8 years ago e9387e7
Add derived 'Data' instances to types.
1 files changed, 14 insertions(+), 13 deletions(-)

M lib/Data/XML/Types.hs
M lib/Data/XML/Types.hs => lib/Data/XML/Types.hs +14 -13
@@ 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]