xml-types 0.3.6 → 0.3.7
raw patch · 4 files changed
+156/−106 lines, 4 filesdep −ghc-primnew-uploader
Dependencies removed: ghc-prim
Files
- COPYING +22/−0
- lib/Data/XML/Types.hs +111/−69
- license.txt +0/−22
- xml-types.cabal +23/−15
+ COPYING view
@@ -0,0 +1,22 @@+Copyright (c) 2010 John Millikin++Permission is hereby granted, free of charge, to any person+obtaining a copy of this software and associated documentation+files (the "Software"), to deal in the Software without+restriction, including without limitation the rights to use,+copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the+Software is furnished to do so, subject to the following+conditions:++The above copyright notice and this permission notice shall be+included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR+OTHER DEALINGS IN THE SOFTWARE.
lib/Data/XML/Types.hs view
@@ -1,16 +1,16 @@ {-# LANGUAGE CPP #-}+#if __GLASGOW_HASKELL__ {-# LANGUAGE DeriveDataTypeable #-}--- if impl(ghc >= 7.2):--- extensions: DeriveGeneric, StandaloneDeriving+#if MIN_VERSION_base(4,4,0)+{-# LANGUAGE DeriveGeneric #-}+#endif+#endif -- | -- Module: Data.XML.Types -- Copyright: 2010-2011 John Millikin -- License: MIT ----- Maintainer: jmillikin@gmail.com--- Portability: portable--- -- Basic types for representing XML. -- -- The idea is to have a full set of appropriate types, which various XML@@ -25,45 +25,45 @@ -- module Data.XML.Types ( -- * Types- + -- ** Document prologue Document (..) , Prologue (..) , Instruction (..) , Miscellaneous (..)- + -- ** Document body , Node (..) , Element (..) , Content (..) , Name (..)- + -- ** Doctypes , Doctype (..) , ExternalID (..)- + -- ** Incremental processing , Event (..)- + -- * Combinators- + -- ** Filters , isElement , isInstruction , isContent , isComment , isNamed- + -- ** Element traversal , elementChildren , elementContent , elementText- + -- ** Node traversal , nodeChildren , nodeContent , nodeText- + -- ** Attributes , hasAttribute , hasAttributeText@@ -72,79 +72,101 @@ ) 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.Typeable (Typeable) import Control.DeepSeq (NFData(rnf)) +#if __GLASGOW_HASKELL__+import Data.Typeable (Typeable)+import Data.Data (Data)+ #if MIN_VERSION_base(4,4,0) import GHC.Generics (Generic) #endif+#endif data Document = Document { documentPrologue :: Prologue , documentRoot :: Element , documentEpilogue :: [Miscellaneous] }- deriving (Data, Eq, Ord, Show, Typeable)+ deriving (Eq, Ord, Show+#if __GLASGOW_HASKELL__+ , Data, Typeable+#if MIN_VERSION_base(4,4,0)+ , Generic+#endif+#endif+ ) instance NFData Document where rnf (Document a b c) = rnf a `seq` rnf b `seq` rnf c `seq` () -#if MIN_VERSION_base(4,4,0)-deriving instance Generic Document-#endif- data Prologue = Prologue { prologueBefore :: [Miscellaneous] , prologueDoctype :: Maybe Doctype , prologueAfter :: [Miscellaneous] }- deriving (Data, Eq, Ord, Show, Typeable)+ deriving (Eq, Ord, Show+#if __GLASGOW_HASKELL__+ , Data, Typeable+#if MIN_VERSION_base(4,4,0)+ , Generic+#endif+#endif+ ) instance NFData Prologue where rnf (Prologue a b c) = rnf a `seq` rnf b `seq` rnf c `seq` () -#if MIN_VERSION_base(4,4,0)-deriving instance Generic Prologue-#endif- data Instruction = Instruction { instructionTarget :: Text , instructionData :: Text }- deriving (Data, Eq, Ord, Show, Typeable)+ deriving (Eq, Ord, Show+#if __GLASGOW_HASKELL__+ , Data, Typeable+#if MIN_VERSION_base(4,4,0)+ , Generic+#endif+#endif+ ) instance NFData Instruction where rnf (Instruction a b) = rnf a `seq` rnf b `seq` () -#if MIN_VERSION_base(4,4,0)-deriving instance Generic Instruction-#endif- data Miscellaneous = MiscInstruction Instruction | MiscComment Text- deriving (Data, Eq, Ord, Show, Typeable)+ deriving (Eq, Ord, Show+#if __GLASGOW_HASKELL__+ , Data, Typeable+#if MIN_VERSION_base(4,4,0)+ , Generic+#endif+#endif+ ) instance NFData Miscellaneous where rnf (MiscInstruction a) = rnf a `seq` () rnf (MiscComment a) = rnf a `seq` () -#if MIN_VERSION_base(4,4,0)-deriving instance Generic Miscellaneous-#endif- data Node = NodeElement Element | NodeInstruction Instruction | NodeContent Content | NodeComment Text- deriving (Data, Eq, Ord, Show, Typeable)+ deriving (Eq, Ord, Show+#if __GLASGOW_HASKELL__+ , Data, Typeable+#if MIN_VERSION_base(4,4,0)+ , Generic+#endif+#endif+ ) instance NFData Node where rnf (NodeElement a) = rnf a `seq` ()@@ -152,36 +174,44 @@ rnf (NodeContent a) = rnf a `seq` () rnf (NodeComment a) = rnf a `seq` () -#if MIN_VERSION_base(4,4,0)-deriving instance Generic Node-#endif+instance IsString Node where+ fromString = NodeContent . fromString data Element = Element { elementName :: Name , elementAttributes :: [(Name, [Content])] , elementNodes :: [Node] }- deriving (Data, Eq, Ord, Show, Typeable)+ deriving (Eq, Ord, Show+#if __GLASGOW_HASKELL__+ , Data, Typeable+#if MIN_VERSION_base(4,4,0)+ , Generic+#endif+#endif+ ) instance NFData Element where rnf (Element a b c) = rnf a `seq` rnf b `seq` rnf c `seq` () -#if MIN_VERSION_base(4,4,0)-deriving instance Generic Element-#endif- data Content = ContentText Text | ContentEntity Text -- ^ For pass-through parsing- deriving (Data, Eq, Ord, Show, Typeable)+ deriving (Eq, Ord, Show+#if __GLASGOW_HASKELL__+ , Data, Typeable+#if MIN_VERSION_base(4,4,0)+ , Generic+#endif+#endif+ ) instance NFData Content where rnf (ContentText a) = rnf a `seq` () rnf (ContentEntity a) = rnf a `seq` () -#if MIN_VERSION_base(4,4,0)-deriving instance Generic Content-#endif+instance IsString Content where+ fromString = ContentText . fromString -- | A fully qualified name. --@@ -203,7 +233,14 @@ , nameNamespace :: Maybe Text , namePrefix :: Maybe Text }- deriving (Data, Show, Typeable)+ deriving (Show+#if __GLASGOW_HASKELL__+ , Data, Typeable+#if MIN_VERSION_base(4,4,0)+ , Generic+#endif+#endif+ ) instance Eq Name where (==) = (==) `on` (\x -> (nameNamespace x, nameLocalName x))@@ -221,10 +258,6 @@ instance NFData Name where rnf (Name a b c) = rnf a `seq` rnf b `seq` rnf c `seq` () -#if MIN_VERSION_base(4,4,0)-deriving instance Generic Name-#endif- -- | Note: due to the incredible complexity of DTDs, this type only supports -- external subsets. I've tried adding internal subset types, but they -- quickly gain more code than the rest of this module put together.@@ -235,28 +268,34 @@ { doctypeName :: Text , doctypeID :: Maybe ExternalID }- deriving (Data, Eq, Ord, Show, Typeable)+ deriving (Eq, Ord, Show+#if __GLASGOW_HASKELL__+ , Data, Typeable+#if MIN_VERSION_base(4,4,0)+ , Generic+#endif+#endif+ ) instance NFData Doctype where rnf (Doctype a b) = rnf a `seq` rnf b `seq` () -#if MIN_VERSION_base(4,4,0)-deriving instance Generic Doctype-#endif- data ExternalID = SystemID Text | PublicID Text Text- deriving (Data, Eq, Ord, Show, Typeable)+ deriving (Eq, Ord, Show+#if __GLASGOW_HASKELL__+ , Data, Typeable+#if MIN_VERSION_base(4,4,0)+ , Generic+#endif+#endif+ ) instance NFData ExternalID where rnf (SystemID a) = rnf a `seq` () rnf (PublicID a b) = rnf a `seq` rnf b `seq` () -#if MIN_VERSION_base(4,4,0)-deriving instance Generic ExternalID-#endif- -- | 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 -- specified as a sequence of events.@@ -280,7 +319,14 @@ | EventContent Content | EventComment Text | EventCDATA Text- deriving (Data, Eq, Ord, Show, Typeable)+ deriving (Eq, Ord, Show+#if __GLASGOW_HASKELL__+ , Data, Typeable+#if MIN_VERSION_base(4,4,0)+ , Generic+#endif+#endif+ ) instance NFData Event where rnf (EventBeginDoctype a b) = rnf a `seq` rnf b `seq` ()@@ -291,10 +337,6 @@ rnf (EventComment a) = rnf a `seq` () rnf (EventCDATA a) = rnf a `seq` () rnf _ = ()--#if MIN_VERSION_base(4,4,0)-deriving instance Generic Event-#endif isElement :: Node -> [Element] isElement (NodeElement e) = [e]
− license.txt
@@ -1,22 +0,0 @@-Copyright (c) 2010 John Millikin--Permission is hereby granted, free of charge, to any person-obtaining a copy of this software and associated documentation-files (the "Software"), to deal in the Software without-restriction, including without limitation the rights to use,-copy, modify, merge, publish, distribute, sublicense, and/or sell-copies of the Software, and to permit persons to whom the-Software is furnished to do so, subject to the following-conditions:--The above copyright notice and this permission notice shall be-included in all copies or substantial portions of the Software.--THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR-OTHER DEALINGS IN THE SOFTWARE.
xml-types.cabal view
@@ -1,34 +1,42 @@ name: xml-types-version: 0.3.6+version: 0.3.7 synopsis: Basic types for representing XML license: MIT-license-file: license.txt+license-file: COPYING author: John Millikin <jmillikin@gmail.com>-maintainer: jmillikin@gmail.com+maintainer: Stephen Paul Weber <singpolyma@singpolyma.net> build-type: Simple-cabal-version: >= 1.6+cabal-version: >= 1.10 category: Text, XML stability: experimental-homepage: https://john-millikin.com/software/haskell-xml/-bug-reports: mailto:jmillikin@gmail.com+homepage: https://git.singpolyma.net/xml-types-haskell+bug-reports: mailto:dev@singpolyma.net+description:+ Basic types for representing XML.+ .+ The idea is to have a full set of appropriate types, which various XML+ libraries can share. Instead of having equivalent-but-incompatible types+ for every binding, parser, or client, they all share the same types can+ can thus interoperate easily.+ .+ This library contains complete types for most parts of an XML document,+ including the prologue, node tree, and doctype. Some basic combinators+ are included for common tasks, including traversing the node tree and+ filtering children. source-repository head type: git- location: https://john-millikin.com/code/haskell-xml-types/+ location: https://git.singpolyma.net/xml-types-haskell source-repository this type: git- location: https://john-millikin.com/code/haskell-xml-types/- tag: xml-types_0.3.6+ location: https://git.singpolyma.net/xml-types-haskell+ tag: 0.3.7 library- ghc-options: -Wall+ default-language: Haskell2010+ ghc-options: -Wall -Wno-tabs hs-source-dirs: lib-- if impl(ghc >= 7.2)- extensions: DeriveGeneric, StandaloneDeriving- if impl(ghc >= 7.2) && impl(ghc < 7.6)- build-depends: ghc-prim build-depends: base >= 3.0 && < 5.0