Portability | requires newtype deriving and MPTCs with fundeps |
---|---|
Stability | experimental |
Maintainer | Niklas Broberg, niklas.broberg@chalmers.se |
Safe Haskell | None |
HSP.XMLGenerator
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.
- 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 Text, Text)
- class Monad m => XMLGen m where
- type XMLType m
- data ChildType m
- data AttributeType m
- genElement :: Name -> [XMLGenT m [AttributeType m]] -> [XMLGenT m [ChildType m]] -> XMLGenT m (XMLType m)
- genEElement :: Name -> [XMLGenT m [AttributeType m]] -> XMLGenT m (XMLType m)
- xmlToChild :: XMLType m -> ChildType m
- pcdataToChild :: Text -> ChildType m
- type GenXML m = XMLGenT m (XMLType m)
- type GenXMLList m = XMLGenT m [XMLType m]
- type GenChild m = XMLGenT m (ChildType m)
- type GenChildList m = XMLGenT m [ChildType m]
- type GenAttribute m = XMLGenT m (AttributeType m)
- type GenAttributeList m = XMLGenT m [AttributeType m]
- class XMLGen m => EmbedAsChild m c where
- asChild :: c -> GenChildList m
- data Attr n a = n := a
- class XMLGen m => EmbedAsAttr m a where
- asAttr :: a -> GenAttributeList m
- class (XMLGen m, SetAttr m (XMLType m), AppendChild m (XMLType m), EmbedAsChild m (XMLType m), EmbedAsChild m [XMLType m], EmbedAsChild m Text, EmbedAsChild m Char, EmbedAsChild m (), EmbedAsAttr m (Attr Text Text), EmbedAsAttr m (Attr Text Int), EmbedAsAttr m (Attr Text Bool)) => XMLGenerator m
- class XMLGen m => SetAttr m elem where
- setAttr :: elem -> GenAttribute m -> GenXML m
- setAll :: elem -> GenAttributeList m -> GenXML m
- (<@) :: (SetAttr m elem, EmbedAsAttr m attr) => elem -> attr -> GenXML m
- set :: (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
- (<:) :: (AppendChild m elem, EmbedAsChild m c) => elem -> c -> GenXML m
- app :: (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
- 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
The monad transformer that allows a monad to generate XML values.
Constructors
XMLGenT (m a) |
Instances
mapXMLGenT :: (m a -> n b) -> XMLGenT m a -> XMLGenT n bSource
map the inner monad
class Monad m => XMLGen m whereSource
Generate XML values in some XMLGenerator monad.
Methods
genElement :: Name -> [XMLGenT m [AttributeType m]] -> [XMLGenT m [ChildType m]] -> XMLGenT m (XMLType m)Source
genEElement :: Name -> [XMLGenT m [AttributeType m]] -> XMLGenT m (XMLType m)Source
xmlToChild :: XMLType m -> ChildType mSource
pcdataToChild :: Text -> ChildType mSource
type GenXML m = XMLGenT m (XMLType m)Source
Type synonyms to avoid writing out the XMLnGenT all the time
type GenXMLList m = XMLGenT m [XMLType m]Source
type GenChildList m = XMLGenT m [ChildType m]Source
type GenAttribute m = XMLGenT m (AttributeType m)Source
type GenAttributeList m = XMLGenT m [AttributeType 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
Instances
XMLGen m => EmbedAsChild m () | |
XMLGen m => EmbedAsChild m Text | |
XMLGen m => EmbedAsChild m String | |
(XMLGen m, ~ * (XMLType m) x) => EmbedAsChild m x | |
XMLGen m => EmbedAsChild m (ChildType m) | |
(XMLGen m, EmbedAsChild m c) => EmbedAsChild m [c] | |
(XMLGen m, EmbedAsChild m c, ~ (* -> *) m n) => EmbedAsChild m (XMLGenT n c) | |
(XMLGen (HSPT XML m), Functor m, Monad m) => EmbedAsChild (HSPT XML m) () | |
(XMLGen (HSPT XML m), Functor m, Monad m) => EmbedAsChild (HSPT XML m) Char | |
(XMLGen (HSPT XML m), Functor m, Monad m) => EmbedAsChild (HSPT XML m) Text | |
(XMLGen (HSPT XML m), Functor m, Monad m) => EmbedAsChild (HSPT XML m) String | |
(XMLGen (HSPT XML m), Functor m, Monad m) => EmbedAsChild (HSPT XML m) XML | |
(XMLGen (HSPT XML m), Functor m, Monad m) => EmbedAsChild (HSPT XML m) [XML] |
Constructors
n := a |
Instances
(XMLGen m, EmbedAsAttr m (Attr a v), TypeCastM m1 m) => EmbedAsAttr m (Attr a (XMLGenT m1 v)) | |
(Show n, Show a) => Show (Attr n a) | |
(XMLGen (HSPT XML m), Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text Text) | |
(XMLGen (HSPT XML m), Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text Int) | |
(XMLGen (HSPT XML m), Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text Bool) | |
(XMLGen (HSPT XML m), Monad m, Functor m) => EmbedAsAttr (HSPT XML m) (Attr Text Char) |
class XMLGen m => EmbedAsAttr m a whereSource
Similarly embed values as attributes of an XML element.
Methods
asAttr :: a -> GenAttributeList mSource
Instances
(XMLGen m, EmbedAsAttr m a) => EmbedAsAttr m [a] | |
XMLGen m => EmbedAsAttr m (AttributeType m) | |
(XMLGen m, EmbedAsAttr m (Attr a v), TypeCastM m1 m) => EmbedAsAttr m (Attr a (XMLGenT m1 v)) | |
(XMLGen m, EmbedAsAttr m a) => EmbedAsAttr m (XMLGenT m a) | |
(XMLGen (HSPT XML m), Monad m, Functor m) => EmbedAsAttr (HSPT XML m) Attribute | |
(XMLGen (HSPT XML m), Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text Text) | |
(XMLGen (HSPT XML m), Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text Int) | |
(XMLGen (HSPT XML m), Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text Bool) | |
(XMLGen (HSPT XML m), Monad m, Functor m) => EmbedAsAttr (HSPT XML m) (Attr Text Char) |
class (XMLGen m, SetAttr m (XMLType m), AppendChild m (XMLType m), EmbedAsChild m (XMLType m), EmbedAsChild m [XMLType m], EmbedAsChild m Text, EmbedAsChild m Char, EmbedAsChild m (), EmbedAsAttr m (Attr Text Text), EmbedAsAttr m (Attr Text Int), EmbedAsAttr m (Attr Text Bool)) => XMLGenerator m Source
Instances
(XMLGen (HSPT XML m), SetAttr (HSPT XML m) (XMLType (HSPT XML m)), AppendChild (HSPT XML m) (XMLType (HSPT XML m)), EmbedAsChild (HSPT XML m) (XMLType (HSPT XML m)), EmbedAsChild (HSPT XML m) [XMLType (HSPT XML m)], EmbedAsChild (HSPT XML m) Text, EmbedAsChild (HSPT XML m) Char, EmbedAsChild (HSPT XML m) (), EmbedAsAttr (HSPT XML m) (Attr Text Text), EmbedAsAttr (HSPT XML m) (Attr Text Int), EmbedAsAttr (HSPT XML m) (Attr Text Bool), Functor m, Monad m) => XMLGenerator (HSPT XML m) |
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
(<@) :: (SetAttr m elem, EmbedAsAttr m attr) => elem -> attr -> GenXML mSource
set :: (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
Instances
(XMLGen m, AppendChild m x, TypeCastM m1 m) => AppendChild m (XMLGenT m1 x) | |
(XMLGen (HSPT XML m), Functor m, Monad m) => AppendChild (HSPT XML m) XML |
(<:) :: (AppendChild m elem, EmbedAsChild m c) => elem -> c -> GenXML mSource
app :: (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.
Instances
IsName String | Strings can represent names, meaning a simple name with no domain. |
IsName Text | Strings can represent names, meaning a simple name with no domain. |
IsName Name | Names can represent names, of course. |
IsName (String, String) | Pairs of strings can represent names, meaning a name qualified with a domain. |
IsName (Text, Text) | Pairs of strings can represent names, meaning a name qualified with a domain. |
class TypeCast' t a b | t a -> b, t b -> a whereSource
Instances
TypeCast'' t a b => TypeCast' t a b |
class TypeCast'' t a b | t a -> b, t b -> a whereSource
Methods
typeCast'' :: t -> a -> bSource
Instances
TypeCast'' () a a |
class TypeCastM ma mb | ma -> mb, mb -> ma whereSource
Instances
TypeCastM' () ma mb => TypeCastM ma mb |
class TypeCastM' t ma mb | t ma -> mb, t mb -> ma whereSource
Methods
typeCastM' :: t -> ma x -> mb xSource
Instances
TypeCastM'' t ma mb => TypeCastM' t ma mb |
class TypeCastM'' t ma mb | t ma -> mb, t mb -> ma whereSource
Methods
typeCastM'' :: t -> ma x -> mb xSource
Instances
TypeCastM'' () ma ma |