packages feed

xml-conduit-writer 0.1.0.0 → 0.1.1.0

raw patch · 3 files changed

+26/−18 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Text.XML.Writer: elementMaybe :: ToXML a => Name -> Maybe a -> XML
- Text.XML.Writer: element :: Name -> XML -> XML
+ Text.XML.Writer: element :: ToXML a => Name -> a -> XML
- Text.XML.Writer: elementA :: Name -> [(Name, Text)] -> XML -> XML
+ Text.XML.Writer: elementA :: ToXML a => Name -> [(Name, Text)] -> a -> XML

Files

src/Text/XML/Writer.hs view
@@ -5,11 +5,11 @@ -- > {-# LANGUAGE OverloadedStrings #-} -- > -- > let doc = document "root" $ do--- >     element "hello" "world"+-- >     element "hello" $ content "world" -- >     element "hierarchy" $ do--- >         element "simple" $ toXML True--- >         element "as" "it should be"--- >         toXML $ Just "like this"+-- >         element "simple" True+-- >         element "as" ("it should be" :: Text)+-- >         toXML $ Just . T.pack $ "like this" -- >     comment "that's it!" -- @@ -24,7 +24,7 @@     , node     , instruction     , comment-    , element, elementA+    , element, elementMaybe, elementA     , content     , empty     , many@@ -64,17 +64,25 @@ render :: XML -> [Node] render = DL.toList . execWriter --- | Insert one node+-- | Do nothing.+empty :: XML+empty = return ()++-- | Insert one node. node :: Node -> XML node = tell . DL.singleton  -- | Insert an "Element" node constructed with name and children.-element :: Name -> XML -> XML-element name children = node . NodeElement $! Element name def (render children)+element :: (ToXML a) => Name -> a -> XML+element name children = node . NodeElement $! Element name def (render $ toXML children) +-- | Insert an "Element" node converted from Maybe value or do nothing.+elementMaybe :: (ToXML a) => Name -> Maybe a -> XML+elementMaybe name = maybe empty (element name)+ -- | Insert an "Element" node constructed with name, attributes and children.-elementA :: Name -> [(Name, Text)] -> XML -> XML-elementA name attrs children = node . NodeElement $! Element name (M.fromList attrs) (render children)+elementA :: (ToXML a) => Name -> [(Name, Text)] -> a -> XML+elementA name attrs children = node . NodeElement $! Element name (M.fromList attrs) (render $ toXML children)  -- | Insert an "Instruction" node. instruction :: Text -> Text -> XML@@ -87,10 +95,6 @@ -- | Insert text content node. content :: Text -> XML content = node . NodeContent---- | Do nothing.-empty :: XML-empty = return ()  -- | Mass-convert to nodes. -- 
test/Main.hs view
@@ -24,7 +24,7 @@ main = do     pprint $ document "root" $ do         element "{ns:uri}pseudo:prefix" $ do-            element "unprefixed" "empty NS"+            element "unprefixed" $ comment "empty NS"             element "pseudo:prefixed" $ comment "wrong!"          element ("sns" !: "{silly:ns:uri}spam") $ do@@ -41,7 +41,7 @@     pprint $ soap () $ do         element ("v" !: "{vendor:uri}request") $ do             element "complex" $ do-                element "key" "value"+                element "key" $ T.pack "value"                 elementA "tag" [("key", "value")] empty             element "text" $ content "some text"             element "bool" $ toXML True
xml-conduit-writer.cabal view
@@ -1,5 +1,5 @@ name:                xml-conduit-writer-version:             0.1.0.0+version:             0.1.1.0 synopsis:            Warm and fuzzy creation of XML documents. description:     “It can scarcely be denied that the supreme goal of@@ -10,7 +10,7 @@     .     Check out more examples in test/Main.hs and     look at the results with --enable-tests.-homepage:            https://bitbucket.org/dpwiz/xml-conduit-monad+homepage:            https://bitbucket.org/dpwiz/xml-conduit-writer license:             MIT license-file:        LICENSE copyright:           Alexander Bondarenko 2013@@ -19,6 +19,10 @@ category:            Text build-type:          Simple cabal-version:       >=1.8++source-repository head+  type: mercurial+  location: https://bitbucket.org/dpwiz/xml-conduit-writer  library   ghc-options: -Wall -O2