-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Warm and fuzzy creation of XML documents.
--   
--   “It can scarcely be denied that the supreme goal of all theory is to
--   make the irreducible basic elements as simple and as few as possible
--   without having to surrender the adequate representation of a single
--   datum of experience.” ­— Albert Einstein . Check out more examples in
--   test/Main.hs and look at the results with --enable-tests.
@package xml-conduit-writer
@version 0.1.1.6

-- | Overcome XML insanity, node by node.
--   
--   
--   {-# LANGUAGE OverloadedStrings #-}
--   
--   let doc = document "root" $ do
--       element "hello" $ content "world"
--       element "hierarchy" $ do
--           element "simple" True
--           element "as" ("it should be" :: Text)
--           toXML $ Just . T.pack $ "like this"
--       comment "that's it!"
--   
module Text.XML.Writer

-- | Create a simple Document starting with a root element.
document :: Name -> XML -> Document

-- | Create a simple Document starting with a root element with attributes.
documentA :: Name -> [(Name, Text)] -> XML -> Document

-- | Create a simple Document starting with a root element with a doctype.
documentD :: Name -> Maybe Doctype -> XML -> Document

-- | Create a simple Document starting with a root element with attributes
--   and doctype.
documentAD :: Name -> [(Name, Text)] -> Maybe Doctype -> XML -> Document

-- | Generate a SOAPv1.1 document.
--   
--   Empty header will be ignored. Envelope uses a soapenv prefix.
--   Works great with ToXML class.
--   
--   
--   data BigData = BigData { webScale :: Bool }
--   instance ToXML BigData where
--       toXML (BigData ws) = element ("v" !: "{vendor:uri}bigData") $ toXML ws
--   let doc = soap () (BigData True)
--   
soap :: (ToXML h, ToXML b) => h -> b -> Document

-- | Render document using xml-conduit's pretty-printer.
pprint :: Document -> IO ()

-- | Node container to be rendered as children nodes.
type XML = Writer DList Node ()

-- | Insert one node.
node :: Node -> XML

-- | Insert an Instruction node.
instruction :: Text -> Text -> XML

-- | Insert a text comment node.
comment :: Text -> XML

-- | Insert an Element node constructed with name and children.
element :: ToXML a => Name -> a -> XML

-- | Insert an Element node converted from Maybe value or do
--   nothing.
elementMaybe :: ToXML a => Name -> Maybe a -> XML

-- | Insert an Element node constructed with name, attributes and
--   children.
elementA :: ToXML a => Name -> [(Name, Text)] -> a -> XML

-- | Insert text content node.
content :: Text -> XML

-- | Do nothing.
empty :: XML

-- | Mass-convert to nodes.
--   
--   
--   let array = element "container" $ many "wrapper" [1..3]
--   
--   
--   Which gives:
--   
--   
--   <container>
--       <wrapper>1</wrapper>
--       <wrapper>2</wrapper>
--       <wrapper>3</wrapper>
--   </container>
--   
--   
--   Use `mapM_ toXML xs` to convert a list without wrapping each item in
--   separate element.
--   
--   
--   let mess = element "container" $ mapM_ toXML ["chunky", "chunk"]
--   
--   
--   Content nodes tend to glue together:
--   
--   
--   <container>chunkychunk</container>
--   
many :: ToXML a => Name -> [a] -> XML

-- | Convert collected nodes to a list of child nodes.
render :: XML -> [Node]

-- | Attach a prefix to a Name.
--   
--   Because simply placing a colon in an element name yields
--   Nothing as a prefix and children will revert to en empty
--   namespace.
(!:) :: Text -> Name -> Name

-- | Provide instances for this class to use your data as XML nodes.
class ToXML a
toXML :: ToXML a => a -> XML
instance GHC.Internal.Data.String.IsString Text.XML.Writer.XML
instance Text.XML.Writer.ToXML GHC.Types.Bool
instance Text.XML.Writer.ToXML GHC.Types.Char
instance Text.XML.Writer.ToXML GHC.Types.Double
instance Text.XML.Writer.ToXML GHC.Types.Float
instance Text.XML.Writer.ToXML GHC.Types.Int
instance Text.XML.Writer.ToXML GHC.Num.Integer.Integer
instance Text.XML.Writer.ToXML a => Text.XML.Writer.ToXML (GHC.Internal.Maybe.Maybe a)
instance Text.XML.Writer.ToXML Data.Text.Internal.Text
instance Text.XML.Writer.ToXML ()
instance Text.XML.Writer.ToXML Text.XML.Writer.XML
