hexpat 0.20.1 → 0.20.2
raw patch · 4 files changed
+35/−36 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Text.XML.Expat.Internal.NodeClass: mapElement :: NodeClass n c => ((tag, [(tag, text)], c (n c tag text)) -> (tag', [(tag', text)], c (n c tag' text))) -> n c tag text -> n c tag' text
Files
- Text/XML/Expat/Internal/NodeClass.hs +0/−9
- Text/XML/Expat/Tree.hs +32/−24
- hexpat.cabal +2/−2
- test/hexpat-tests.cabal +1/−1
Text/XML/Expat/Internal/NodeClass.hs view
@@ -109,15 +109,6 @@ -- | Generic text node constructor. mkText :: text -> n c tag text --- | DEPRECATED. Map an element non-recursively, allowing the tag type to be changed.-mapElement :: NodeClass n c =>- ((tag, [(tag, text)], c (n c tag text))- -> (tag', [(tag', text)], c (n c tag' text)))- -> n c tag text- -> n c tag' text-{-# DEPRECATED mapElement "renamed to modifyElement" #-}-mapElement = modifyElement- -- | Change a list of nodes recursively from one container type to another, with -- a specified function to convert the container type. mapNodeListContainer :: (NodeClass n c, List c') =>
Text/XML/Expat/Tree.hs view
@@ -1,5 +1,5 @@ {-# LANGUAGE DeriveDataTypeable, TypeSynonymInstances, FlexibleInstances,- MultiParamTypeClasses, TypeFamilies #-}+ MultiParamTypeClasses, TypeFamilies, ScopedTypeVariables #-} -- hexpat, a Haskell wrapper for expat -- Copyright (C) 2008 Evan Martin <martine@danga.com>@@ -304,33 +304,41 @@ -- | A lower level function that converts a generalized SAX stream into a tree structure. -- Ignores parse errors.-saxToTreeG :: (GenericXMLString tag, List l) =>+saxToTreeG :: forall tag text l . (GenericXMLString tag, List l) => l (SAXEvent tag text) -> ItemM l (NodeG l tag text) saxToTreeG events = do- (elts, _) <- process events- findRoot elts+ li <- runList (process events)+ case li of+ Cons elt@(Element _ _ _ ) _ -> return elt+ _ -> return $ Element (gxFromString "") mzero mzero where- findRoot elts = do- li <- runList elts- case li of- Cons elt@(Element _ _ _ ) _ -> return elt- Cons _ rema -> findRoot rema- Nil -> return $ Element (gxFromString "") mzero mzero- process events = do- li <- runList events- case li of- Nil -> return (mzero, mzero)- Cons (StartElement name attrs) rema -> do- (children, rema') <- process rema- (out, rema'') <- process rema'- return (Element name attrs children `cons` out, rema'')- Cons (EndElement _) rema -> return (mzero, rema)- Cons (CharacterData txt) rema -> do- (out, rema') <- process rema- return (Text txt `cons` out, rema')- --Cons (FailDocument err) rema = (mzero, mzero)- Cons _ rema -> process rema+ process :: l (SAXEvent tag text) -> l (NodeG l tag text)+ process events = joinL $ process_ events+ where+ process_ :: l (SAXEvent tag text) -> ItemM l (l (NodeG l tag text))+ process_ events = do+ li <- runList events+ case li of+ Nil -> return mzero+ Cons (StartElement name attrs) rema -> do+ return $ Element name attrs (process rema) `cons` process (stripElement rema)+ Cons (EndElement _) _ -> return mzero+ Cons (CharacterData txt) rema -> return $ Text txt `cons` process rema+ Cons _ rema -> process_ rema++ stripElement :: l (SAXEvent tag text) -> l (SAXEvent tag text)+ stripElement events = joinL $ stripElement_ 0 events+ where+ stripElement_ :: Int -> l (SAXEvent tag text) -> ItemM l (l (SAXEvent tag text))+ stripElement_ level events = level `seq` do+ li <- runList events+ case li of+ Nil -> return mzero+ Cons (StartElement _ _) rema -> stripElement_ (level+1) rema+ Cons (EndElement _) rema -> if level == 0 then return rema + else stripElement_ (level-1) rema+ Cons _ rema -> stripElement_ level rema -- | Lazily parse XML to tree. Note that forcing the XMLParseError return value -- will force the entire parse. Therefore, to ensure lazy operation, don't
hexpat.cabal view
@@ -1,6 +1,6 @@ Cabal-Version: >= 1.6 Name: hexpat-Version: 0.20.1+Version: 0.20.2 Synopsis: XML parser/formatter based on expat Description: This package provides a general purpose Haskell XML library using Expat to@@ -47,7 +47,7 @@ 0.19.7 ghc-7.2.1 compatibility; 0.19.8 fix space leak on lazy parse under ghc-7.2.1; 0.19.9 fix formatting of > character + improve performance; 0.19.10 ghc-7.4.x compatibility; 0.20.1 fix an unfortunate crash when used in parallel processing and greatly improve- performance.+ performance; 0.20.2 make parseSaxG lazier. Category: XML License: BSD3 License-File: LICENSE
test/hexpat-tests.cabal view
@@ -9,7 +9,7 @@ build-depends: HUnit < 1.3,- QuickCheck == 2.4.*,+ QuickCheck >= 2.4.0.0 && < 2.6.0.0, base >= 3 && < 5, bytestring, containers,