module Text.XML.ParentAttributes
( ToXmlParentAttributes(..)
, ToXmlAttribute(..)
, toXmlAttributeIntegral
) where
import Data.Text as T.S
import Data.Text.Lazy as T.L
import Data.Text.Lazy.Builder as T.L
import Data.Text.Lazy.Builder.Int as T.L
import Numeric.Natural
import Text.XML
class ToXmlParentAttributes a where
toXmlParentAttributes :: a -> [(Name, T.S.Text)]
instance {-# OVERLAPPABLE #-} ToXmlParentAttributes a where
toXmlParentAttributes _ = []
class ToXmlAttribute a where
toXmlAttribute :: a -> T.S.Text
instance ToXmlAttribute T.S.Text where
toXmlAttribute = id
toXmlAttributeIntegral :: Integral a => a -> T.S.Text
toXmlAttributeIntegral = T.L.toStrict . T.L.toLazyText . T.L.decimal
instance ToXmlAttribute Int where
toXmlAttribute = toXmlAttributeIntegral
instance ToXmlAttribute Word where
toXmlAttribute = toXmlAttributeIntegral
instance ToXmlAttribute Integer where
toXmlAttribute = toXmlAttributeIntegral
instance ToXmlAttribute Natural where
toXmlAttribute = toXmlAttributeIntegral