~singpolyma/xml-types-haskell

bd7a280171bb0f5255988d9b081e0301e35447d3 — John Millikin 11 years ago 1041f38
Store attributes in an association list.
2 files changed, 3 insertions(+), 5 deletions(-)

M Data/XML/Types.hs
M xml-types.cabal
M Data/XML/Types.hs => Data/XML/Types.hs +3 -4
@@ 68,7 68,6 @@ module Data.XML.Types
	, attributeText
	) where
import Control.Monad ((>=>))
import qualified Data.Map as M
import Data.Maybe (isJust)
import Data.Text (Text)
import qualified Data.Text as T


@@ 126,7 125,7 @@ instance Typeable Node where

data Element = Element
	{ elementName :: Name
	, elementAttributes :: M.Map Name [Content]
	, elementAttributes :: [(Name, [Content])]
	, elementNodes :: [Node]
	}
	deriving (Show, Eq)


@@ 242,7 241,7 @@ data Event
	| EventDeclaration Declaration
	| EventEndDoctype
	| EventInstruction Instruction
	| EventBeginElement Name (M.Map Name [Content])
	| EventBeginElement Name [(Name, [Content])]
	| EventEndElement Name
	| EventContent Content
	| EventComment Text


@@ 296,7 295,7 @@ hasAttributeText :: Name -> (Text -> Bool) -> Element -> [Element]
hasAttributeText name p e = [e | maybe False p (attributeText name e)]

attributeContent :: Name -> Element -> Maybe [Content]
attributeContent name e = M.lookup name (elementAttributes e)
attributeContent name e = lookup name (elementAttributes e)

attributeText :: Name -> Element -> Maybe Text
attributeText name e = fmap contentFlat (attributeContent name e)

M xml-types.cabal => xml-types.cabal +0 -1
@@ 21,7 21,6 @@ library
  build-depends:
      base >=3 && < 5
    , text
    , containers

  exposed-modules:
    Data.XML.Types