Google

>
 HaXmlParentContentsIndex
Text.XML.HaXml.Haskell2Xml
Contents
Re-export the entire set of XML type definitions
The class Haskell2Xml
Conversion functions
IO functions
Auxiliary types
Description

The class Haskell2Xml is a replacement for Read and Show: it provides textual conversions (to and from an XML representation) for your Haskell data values. Use the tool DrIFT to derive this class for your own datatypes, then include this module where you want to use the facilities.

The methods toContents and fromContents convert a value to and from a generic internal representation of an XML document without a DTD. The functions toXml and fromXml convert a value to and from a generic internal representation of an XML document including a DTD. The functions readXml and writeXml do the conversion to and from the given filenames. The functions hReadXml and hWriteXml do the conversion to and from the given file handles. (See the type signatures.)

Synopsis
module Text.XML.HaXml.Types
class Haskell2Xml a where
xFromChar :: Char -> a
xToChar :: a -> Char
fromContents :: [Content] -> (a, [Content])
toContents :: a -> [Content]
toHType :: a -> HType
toXml :: (Haskell2Xml a) => a -> Document
toDTD :: HType -> DocTypeDecl
fromXml :: (Haskell2Xml a) => Document -> a
readXml :: (Haskell2Xml a) => FilePath -> IO a
writeXml :: (Haskell2Xml a) => FilePath -> a -> IO ()
hReadXml :: (Haskell2Xml a) => Handle -> IO a
hWriteXml :: (Haskell2Xml a) => Handle -> a -> IO ()
data HType
= Maybe HType
| List HType
| Tuple [HType]
| Prim String String
| String
| Defined String [HType] [Constr]
data Constr = Constr String [HType] [HType]
Re-export the entire set of XML type definitions
module Text.XML.HaXml.Types
The class Haskell2Xml
class Haskell2Xml a where
A class to convert any Haskell value to and from an XML representation.
Methods
xFromChar :: Char -> a
xToChar :: a -> Char
fromContents :: [Content] -> (a, [Content])
This function is a dummy for most types: it is used only in the Char instance for coercing lists of Char into String.
toContents :: a -> [Content]
Parse a Haskell value from a generic XML representation, returning the value and the remainder of the XML.
toHType :: a -> HType
Convert the Haskell value to a generic XML value.
Instances
Haskell2Xml Bool
Haskell2Xml Int
Haskell2Xml Integer
Haskell2Xml Float
Haskell2Xml Double
Haskell2Xml Char
(Haskell2Xml a) => Haskell2Xml [a]
(Haskell2Xml a, Haskell2Xml b) => Haskell2Xml (a, b)
(Haskell2Xml a) => Haskell2Xml (Maybe a)
(Haskell2Xml a, Haskell2Xml b) => Haskell2Xml (Either a b)
Haskell2Xml ()
Conversion functions
toXml :: (Haskell2Xml a) => a -> Document
Convert any Haskell value to an XML document, including both DTD and content.
toDTD :: HType -> DocTypeDecl
toDTD converts a concrete representation of the Haskell type of a value (obtained by the method toHType) into a real DocTypeDecl. It ensures that PERefs are defined before they are used, and that no element or attribute-list is declared more than once.
fromXml :: (Haskell2Xml a) => Document -> a
Read a Haskell value from an XML document, ignoring the DTD and using the Haskell result type to determine how to parse it.
IO functions
readXml :: (Haskell2Xml a) => FilePath -> IO a
Read a Haskell value from an XML document stored in a file.
writeXml :: (Haskell2Xml a) => FilePath -> a -> IO ()
Write a Haskell value to the given file as an XML document.
hReadXml :: (Haskell2Xml a) => Handle -> IO a
Read a Haskell value from an XML document transmitted through the given Handle.
hWriteXml :: (Haskell2Xml a) => Handle -> a -> IO ()
Write a Haskell value to the given Handle as an XML document.
Auxiliary types
data HType
A concrete representation of any Haskell type.
Constructors
Maybe HType
List HType
Tuple [HType]
Prim String String separate Haskell name and Xml name
String
Defined String [HType] [Constr] A user-defined type has a name, a sequence of type variables, and a set of constructors.
Instances
Eq HType
data Constr
A concrete representation of any user-defined Haskell constructor. The constructor has a name, and a sequence of component types. The first sequence of types represents the minimum set of free type variables occurring in the (second) list of real component types.
Constructors
Constr String [HType] [HType]
Produced by Haddock version 0.4