xml-isogen-0.3.0: Generate XML-isomorphic types

Safe HaskellNone
LanguageHaskell2010

Text.XML.ParentAttributes

Documentation

class ToXmlParentAttributes a where Source #

Minimal complete definition

toXmlParentAttributes

Methods

toXmlParentAttributes :: a -> [(Name, Text)] Source #

Instances

ToXmlParentAttributes a Source #

A catch-all instance: by default objects don't have parent attributes. The alternative solution is to write a default implementation in the class, but it has a drawback that it requires numerous (boilerplate) empty instances - one for each type that doesn't have parent attributes (most types). This overlappable instance gets overriden for XML records (described in Data.THGen.XML) because they can store parent attributes added via the !% and ?% operators. For example, toXmlParentAttributes applied to a Text or Integer value returns [] because of this instance. However, an XML record defined as Foo =:= record !% "bar" will have its own TH-generated ToXmlParentAttributes instance that inspects the value of its bar field and returns it as an attribute. This way the TH-generators can safely apply toXmlParentAttributes to any value without worrying about missing instances.

Methods

toXmlParentAttributes :: a -> [(Name, Text)] Source #