hsx-0.7.0: HSX (Haskell Source with XML) allows literal XML syntax to be used in Haskell source code.Source codeContentsIndex
HSX.XMLGenerator
Portabilityrequires newtype deriving and MPTCs with fundeps
Stabilityexperimental
MaintainerNiklas Broberg, niklas.broberg@chalmers.se
Description
The class and monad transformer that forms the basis of the literal XML syntax translation. Literal tags will be translated into functions of the GenerateXML class, and any instantiating monads with associated XML types can benefit from that syntax.
Synopsis
newtype XMLGenT m a = XMLGenT (m a)
unXMLGenT :: XMLGenT m a -> m a
mapXMLGenT :: (m a -> n b) -> XMLGenT m a -> XMLGenT n b
type Name = (Maybe String, String)
class Monad m => XMLGen m where
type XML m
data Child m
data Attribute m
genElement :: Name -> [XMLGenT m [Attribute m]] -> [XMLGenT m [Child m]] -> XMLGenT m (XML m)
genEElement :: Name -> [XMLGenT m [Attribute m]] -> XMLGenT m (XML m)
xmlToChild :: XML m -> Child m
pcdataToChild :: String -> Child m
type GenXML m = XMLGenT m (XML m)
type GenXMLList m = XMLGenT m [XML m]
type GenChild m = XMLGenT m (Child m)
type GenChildList m = XMLGenT m [Child m]
type GenAttribute m = XMLGenT m (Attribute m)
type GenAttributeList m = XMLGenT m [Attribute m]
class XMLGen m => EmbedAsChild m c where
asChild :: c -> GenChildList m
class XMLGen m => EmbedAsAttr m a where
asAttr :: a -> GenAttributeList m
class (XMLGen m, SetAttr m (XML m), AppendChild m (XML m), EmbedAsChild m String, EmbedAsChild m Char, EmbedAsAttr m (Attr String String), EmbedAsAttr m (Attr String Int), EmbedAsAttr m (Attr String Bool)) => XMLGenerator m
data Attr n a = n := a
class XMLGen m => SetAttr m elem where
setAttr :: elem -> GenAttribute m -> GenXML m
setAll :: elem -> GenAttributeList m -> GenXML m
set :: (SetAttr m elem, EmbedAsAttr m attr) => elem -> attr -> GenXML m
(<@) :: (SetAttr m elem, EmbedAsAttr m attr) => elem -> attr -> GenXML m
(<<@) :: (SetAttr m elem, EmbedAsAttr m a) => elem -> [a] -> GenXML m
class XMLGen m => AppendChild m elem where
appChild :: elem -> GenChild m -> GenXML m
appAll :: elem -> GenChildList m -> GenXML m
app :: (AppendChild m elem, EmbedAsChild m c) => elem -> c -> GenXML m
(<:) :: (AppendChild m elem, EmbedAsChild m c) => elem -> c -> GenXML m
(<<:) :: (AppendChild m elem, EmbedAsChild m c) => elem -> [c] -> GenXML m
class Show n => IsName n where
toName :: n -> Name
class TypeCast a b | a -> b, b -> a where
typeCast :: a -> b
class TypeCast' t a b | t a -> b, t b -> a where
typeCast' :: t -> a -> b
class TypeCast'' t a b | t a -> b, t b -> a where
typeCast'' :: t -> a -> b
class TypeCastM ma mb | ma -> mb, mb -> ma where
typeCastM :: ma x -> mb x
class TypeCastM' t ma mb | t ma -> mb, t mb -> ma where
typeCastM' :: t -> ma x -> mb x
class TypeCastM'' t ma mb | t ma -> mb, t mb -> ma where
typeCastM'' :: t -> ma x -> mb x
Documentation
newtype XMLGenT m a Source
The monad transformer that allows a monad to generate XML values.
Constructors
XMLGenT (m a)
unXMLGenT :: XMLGenT m a -> m aSource
un-lift.
mapXMLGenT :: (m a -> n b) -> XMLGenT m a -> XMLGenT n bSource
map the inner monad
type Name = (Maybe String, String)Source
class Monad m => XMLGen m whereSource
Generate XML values in some XMLGenerator monad.
Associated Types
type XML m Source
data Child m Source
data Attribute m Source
Methods
genElement :: Name -> [XMLGenT m [Attribute m]] -> [XMLGenT m [Child m]] -> XMLGenT m (XML m)Source
genEElement :: Name -> [XMLGenT m [Attribute m]] -> XMLGenT m (XML m)Source
xmlToChild :: XML m -> Child mSource
pcdataToChild :: String -> Child mSource
type GenXML m = XMLGenT m (XML m)Source
Type synonyms to avoid writing out the XMLnGenT all the time
type GenXMLList m = XMLGenT m [XML m]Source
type GenChild m = XMLGenT m (Child m)Source
type GenChildList m = XMLGenT m [Child m]Source
type GenAttribute m = XMLGenT m (Attribute m)Source
type GenAttributeList m = XMLGenT m [Attribute m]Source
class XMLGen m => EmbedAsChild m c whereSource
Embed values as child nodes of an XML element. The parent type will be clear from the context so it is not mentioned.
Methods
asChild :: c -> GenChildList mSource
class XMLGen m => EmbedAsAttr m a whereSource
Similarly embed values as attributes of an XML element.
Methods
asAttr :: a -> GenAttributeList mSource
class (XMLGen m, SetAttr m (XML m), AppendChild m (XML m), EmbedAsChild m String, EmbedAsChild m Char, EmbedAsAttr m (Attr String String), EmbedAsAttr m (Attr String Int), EmbedAsAttr m (Attr String Bool)) => XMLGenerator m Source
data Attr n a Source
Constructors
n := a
class XMLGen m => SetAttr m elem whereSource
Set attributes on XML elements
Methods
setAttr :: elem -> GenAttribute m -> GenXML mSource
setAll :: elem -> GenAttributeList m -> GenXML mSource
set :: (SetAttr m elem, EmbedAsAttr m attr) => elem -> attr -> GenXML mSource
(<@) :: (SetAttr m elem, EmbedAsAttr m attr) => elem -> attr -> GenXML mSource
(<<@) :: (SetAttr m elem, EmbedAsAttr m a) => elem -> [a] -> GenXML mSource
class XMLGen m => AppendChild m elem whereSource
Methods
appChild :: elem -> GenChild m -> GenXML mSource
appAll :: elem -> GenChildList m -> GenXML mSource
app :: (AppendChild m elem, EmbedAsChild m c) => elem -> c -> GenXML mSource
(<:) :: (AppendChild m elem, EmbedAsChild m c) => elem -> c -> GenXML mSource
(<<:) :: (AppendChild m elem, EmbedAsChild m c) => elem -> [c] -> GenXML mSource
class Show n => IsName n whereSource
Names can be simple or qualified with a domain. We want to conveniently use both simple strings or pairs wherever a Name is expected.
Methods
toName :: n -> NameSource
class TypeCast a b | a -> b, b -> a whereSource
Methods
typeCast :: a -> bSource
class TypeCast' t a b | t a -> b, t b -> a whereSource
Methods
typeCast' :: t -> a -> bSource
class TypeCast'' t a b | t a -> b, t b -> a whereSource
Methods
typeCast'' :: t -> a -> bSource
class TypeCastM ma mb | ma -> mb, mb -> ma whereSource
Methods
typeCastM :: ma x -> mb xSource
class TypeCastM' t ma mb | t ma -> mb, t mb -> ma whereSource
Methods
typeCastM' :: t -> ma x -> mb xSource
class TypeCastM'' t ma mb | t ma -> mb, t mb -> ma whereSource
Methods
typeCastM'' :: t -> ma x -> mb xSource
Produced by Haddock version 2.6.1