@@ 62,6 62,7 @@ import Control.Monad ((>=>))
import Data.Text.Lazy (Text)
import qualified Data.Text.Lazy as T
import Data.String (IsString, fromString)
+import Data.Function (on)
data Document = Document
{ documentPrologue :: Prologue
@@ 81,7 82,7 @@ data Instruction = Instruction
{ instructionTarget :: Text
, instructionData :: Text
}
- deriving (Show, Eq)
+ deriving (Show, Eq, Ord)
data Miscellaneous
= MiscInstruction Instruction
@@ 113,11 114,6 @@ data Content
| ContentEntity Text
deriving (Show, Eq)
--- | The 'Eq' instance for 'Name' ignores prefixes.
---
--- The 'IsString' instance for 'Name' allows entry using Clark notation;
--- see <http://www.jclark.com/xml/xmlns.htm> and
--- <http://infohost.nmt.edu/tcc/help/pubs/pylxml/etree-QName.html>
data Name = Name
{ nameLocalName :: Text
, nameNamespace :: Maybe Text
@@ 125,13 121,20 @@ data Name = Name
}
deriving (Show)
--- Ignore prefixes when comparing names
+-- | Ignores prefixes
instance Eq Name where
- x == y = and
- [ nameLocalName x == nameLocalName y
- , nameNamespace x == nameNamespace y
- ]
+ (==) = (==) `on` (\x -> (nameNamespace x, nameLocalName x))
+
+-- | Ignores prefixes
+--
+-- Since 0.1.3
+instance Ord Name where
+ compare = compare `on` (\x -> (nameNamespace x, nameLocalName x))
+-- | Supports Clark notation; see <http://www.jclark.com/xml/xmlns.htm> and
+-- <http://infohost.nmt.edu/tcc/help/pubs/pylxml/etree-QName.html>
+--
+-- Since 0.1.2
instance IsString Name where
fromString "" = Name T.empty Nothing Nothing
fromString full@('{':rest) = case break (== '}') rest of
@@ 155,10 158,14 @@ data Doctype = Doctype
}
deriving (Show, Eq)
+-- | Since 0.1.3
+instance Ord Doctype where
+ compare = compare `on` (\x -> (doctypeName x, doctypeExternalID x))
+
data ExternalID
= SystemID Text
| PublicID Text Text
- deriving (Show, Eq)
+ deriving (Show, Eq, Ord)
data InternalSubset = InternalSubset
-- TODO