xml-types 0.3.4 → 0.3.8
raw patch · 4 files changed
Files
- COPYING +22/−0
- lib/Data/XML/Types.hs +118/−25
- license.txt +0/−22
- xml-types.cabal +22/−9
+ 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,13 +1,16 @@+{-# LANGUAGE CPP #-}+#if __GLASGOW_HASKELL__ {-# LANGUAGE DeriveDataTypeable #-}+#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@@ -22,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@@ -69,21 +72,35 @@ ) 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` ()@@ -93,7 +110,14 @@ , 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` ()@@ -102,7 +126,14 @@ { 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` ()@@ -110,7 +141,14 @@ 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` ()@@ -121,7 +159,14 @@ | 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` ()@@ -129,12 +174,22 @@ rnf (NodeContent a) = rnf a `seq` () rnf (NodeComment a) = rnf a `seq` () +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` ()@@ -142,12 +197,22 @@ 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` () +instance IsString Content where+ fromString = ContentText . fromString+ -- | A fully qualified name. -- -- Prefixes are not semantically important; they are included only to@@ -168,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))@@ -196,7 +268,14 @@ { 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` ()@@ -204,7 +283,14 @@ 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` ()@@ -233,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` ()
− 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,27 +1,40 @@ name: xml-types-version: 0.3.4+version: 0.3.8 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.4+ location: https://git.singpolyma.net/xml-types-haskell+ tag: 0.3.8 library+ default-language: Haskell2010 ghc-options: -Wall hs-source-dirs: lib