Skip to content

Commit

Permalink
Fixed haddock. Removed unused functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
finnsson committed Jun 9, 2010
1 parent 64b803d commit 1c95a09
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 32 deletions.
8 changes: 4 additions & 4 deletions Text.XML.Generic.cabal
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
name: text-xml-generic
version: 0.0.1
version: 0.1.1
cabal-version: -any
build-type: Simple
license: WTFPL
license: OtherLicense
license-file: "COPYING.txt"
copyright:
maintainer: Oscar Finnsson
build-depends: base >= 4.2, template-haskell, haskell98, Utilities >= 0.1.1, xml >= 1.3.4, syb >= 0.1.0.2, split >= 0.1.2, containers >= 0.3, bytestring >= 0.9.1.5, mtl >= 1.1
build-depends: base >= 4.2, not-in-base >= 0.1.1, template-haskell, haskell98, xml >= 1.3.4, syb >= 0.1.0.2, split >= 0.1.2, containers >= 0.3, bytestring >= 0.9.1.5, mtl >= 1.1
stability:
homepage: http://github.com/finnsson/Text.XML.Generic
package-url:
bug-reports:
synopsis: Serialize Data to XML (strings).
description:
@Text.XML.Generic@ can automatically serialize from the Data-type class to XML-strings.
category:
category: XML
author: Oscar Finnsson
tested-with:
data-files:
Expand Down
37 changes: 10 additions & 27 deletions src/Text/XML/Generic.hs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{-# LANGUAGE DeriveDataTypeable, PackageImports, GADTs, RankNTypes #-}
{-# LANGUAGE DeriveDataTypeable, PackageImports, GADTs, RankNTypes, TypeSynonymInstances, FlexibleInstances, UndecidableInstances, TypeSynonymInstances #-}
module Text.XML.Generic (
-- ** Decode
decodeUnknownXML,
decodeUnknownXML',
fromUnknownXML,
decodeXML,
fromXML,
-- ** Encode
encodeUnknownXML,
encodeXML,
toXML,
-- ** DataBox
DataBox (..)
) where

Expand All @@ -16,7 +18,7 @@ import Data.Generics
import Data.List.Split
import Data.List
import Data.Data
import Utilities.Misc
import NIB.String
import Data.Maybe

import Data.Int
Expand All @@ -28,10 +30,8 @@ import Data.Char

import "mtl" Control.Monad.State

-- FROM

decodeUnknownXML' :: String -> DataBox
decodeUnknownXML' xml = maybe undefined fromUnknownXML' (parseXMLDoc xml)
--------------------------------------------------------------------------
-- ** Decode

decodeUnknownXML :: Data a => String -> (a -> b) -> b
decodeUnknownXML xml fn = fn $ decodeXML xml
Expand Down Expand Up @@ -60,25 +60,6 @@ type F a = Element -> a
fromUnknownXML :: Data a => Element -> (a -> b) -> b
fromUnknownXML xml fn = fn $ fromXML xml

fromUnknownXML' :: Element -> DataBox
fromUnknownXML' x = res
where
res = evalState ( fromConstrM f con ) children
where f :: (Data a) => State [Element] a
f = do es <- get
do put (tail es)
return $ fromXML (head es)
-- get type of first term from e
name = qName $ elName x
myDataType :: DataType
myDataType = dataTypeOf res

children :: [Element]
children = [e | Elem e <- elContent x]

con :: Constr
con = fromMaybe undefined $ readConstr myDataType name

fromXML :: Data d => Element -> d
fromXML e = fromXML'' e'
where
Expand Down Expand Up @@ -142,7 +123,8 @@ fromXML' x = res
myDataType = dataTypeOf res


-- TO
--------------------------------------------------------------------------
-- ** Encode

encodeUnknownXML :: DataBox -> String
encodeUnknownXML (DataBox b) = encodeXML b
Expand Down Expand Up @@ -284,3 +266,4 @@ dbBool = DataBox

instance Eq DataBox where
(==) = geq

2 changes: 1 addition & 1 deletion src/Text/XML/TestGeneric.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Text.XML.Generic
import Text.XML.Light
import Data.Generics.Aliases
import Data.Data
import Utilities.Misc
-- import Utilities.Misc

import Data.Char

Expand Down

0 comments on commit 1c95a09

Please sign in to comment.