~singpolyma/xml-types-haskell

af2c1204417757ba38af9c623e1df15e32c67275 — John Millikin 5 years ago 3fa2cf4 xml-types_0.3.5
Add instances of Generic for GHC >= 7.2.

Bump version to 0.3.5.
2 files changed, 56 insertions(+), 2 deletions(-)

M lib/Data/XML/Types.hs
M xml-types.cabal
M lib/Data/XML/Types.hs => lib/Data/XML/Types.hs +51 -0
@@ 1,4 1,7 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-}
-- if impl(ghc >= 7.2):
--   extensions: DeriveGeneric, StandaloneDeriving

-- |
-- Module: Data.XML.Types


@@ 78,6 81,10 @@ import qualified Data.Text as T
import           Data.Typeable (Typeable)
import           Control.DeepSeq (NFData(rnf))

#if MIN_VERSION_base(4,4,0)
import           GHC.Generics (Generic)
#endif

data Document = Document
	{ documentPrologue :: Prologue
	, documentRoot :: Element


@@ 88,6 95,10 @@ data Document = Document
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


@@ 98,6 109,10 @@ data Prologue = Prologue
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


@@ 107,6 122,10 @@ data Instruction = Instruction
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


@@ 116,6 135,10 @@ 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


@@ 129,6 152,10 @@ instance NFData Node where
	rnf (NodeContent a)     = rnf a `seq` ()
	rnf (NodeComment a)     = rnf a `seq` ()

#if MIN_VERSION_base(4,4,0)
deriving instance Generic Node
#endif

data Element = Element
	{ elementName :: Name
	, elementAttributes :: [(Name, [Content])]


@@ 139,6 166,10 @@ data Element = Element
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


@@ 148,6 179,10 @@ 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

-- | A fully qualified name.
--
-- Prefixes are not semantically important; they are included only to


@@ 186,6 221,10 @@ instance IsString Name where
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.


@@ 201,6 240,10 @@ data Doctype = Doctype
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


@@ 210,6 253,10 @@ 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.


@@ 245,6 292,10 @@ instance NFData Event where
	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]
isElement _ = []

M xml-types.cabal => xml-types.cabal +5 -2
@@ 1,5 1,5 @@
name: xml-types
version: 0.3.4
version: 0.3.5
synopsis: Basic types for representing XML
license: MIT
license-file: license.txt


@@ 19,12 19,15 @@ source-repository head
source-repository this
  type: git
  location: https://john-millikin.com/code/haskell-xml-types/
  tag: xml-types_0.3.4
  tag: xml-types_0.3.5

library
  ghc-options: -Wall
  hs-source-dirs: lib

  if impl(ghc >= 7.2)
    extensions: DeriveGeneric, StandaloneDeriving

  build-depends:
      base >= 3.0 && < 5.0
    , deepseq >= 1.1.0.0