hsp-0.10.0: Haskell Server Pages is a library for writing dynamic server-side web pages.

Copyright(c) Niklas Broberg 2008-2013
LicenseBSD-style (see the file LICENSE.txt)
MaintainerNiklas Broberg <niklas.broberg@gmail.com>
Stabilityexperimental
Portabilityrequires newtype deriving and MPTCs with fundeps and type families
Safe HaskellNone
LanguageHaskell98

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.

Synopsis

Documentation

newtype XMLGenT m a Source #

The monad transformer that allows a monad to generate XML values.

Constructors

XMLGenT (m a) 

Instances

MonadTrans XMLGenT Source # 

Methods

lift :: Monad m => m a -> XMLGenT m a #

MonadRWS r w s m => MonadRWS r w s (XMLGenT m) Source # 
MonadError e m => MonadError e (XMLGenT m) Source # 

Methods

throwError :: e -> XMLGenT m a #

catchError :: XMLGenT m a -> (e -> XMLGenT m a) -> XMLGenT m a #

MonadReader r m => MonadReader r (XMLGenT m) Source # 

Methods

ask :: XMLGenT m r #

local :: (r -> r) -> XMLGenT m a -> XMLGenT m a #

reader :: (r -> a) -> XMLGenT m a #

MonadState s m => MonadState s (XMLGenT m) Source # 

Methods

get :: XMLGenT m s #

put :: s -> XMLGenT m () #

state :: (s -> (a, s)) -> XMLGenT m a #

MonadWriter w m => MonadWriter w (XMLGenT m) Source # 

Methods

writer :: (a, w) -> XMLGenT m a #

tell :: w -> XMLGenT m () #

listen :: XMLGenT m a -> XMLGenT m (a, w) #

pass :: XMLGenT m (a, w -> w) -> XMLGenT m a #

(AppendChild m x, TypeCastM m1 m) => AppendChild m (XMLGenT m1 x) Source # 

Methods

appChild :: XMLGenT m1 x -> GenChild m -> GenXML m Source #

appAll :: XMLGenT m1 x -> GenChildList m -> GenXML m Source #

(TypeCastM m1 m, SetAttr m x) => SetAttr m (XMLGenT m1 x) Source # 
(EmbedAsAttr m (Attr a v), TypeCastM m1 m) => EmbedAsAttr m (Attr a (XMLGenT m1 v)) Source # 

Methods

asAttr :: Attr a (XMLGenT m1 v) -> GenAttributeList m Source #

(XMLGen m, EmbedAsAttr m a) => EmbedAsAttr m (XMLGenT m a) Source # 
(EmbedAsChild m c, (~) (* -> *) m n) => EmbedAsChild m (XMLGenT n c) Source # 

Methods

asChild :: XMLGenT n c -> GenChildList m Source #

Monad m => Monad (XMLGenT m) Source # 

Methods

(>>=) :: XMLGenT m a -> (a -> XMLGenT m b) -> XMLGenT m b #

(>>) :: XMLGenT m a -> XMLGenT m b -> XMLGenT m b #

return :: a -> XMLGenT m a #

fail :: String -> XMLGenT m a #

Functor m => Functor (XMLGenT m) Source # 

Methods

fmap :: (a -> b) -> XMLGenT m a -> XMLGenT m b #

(<$) :: a -> XMLGenT m b -> XMLGenT m a #

Applicative m => Applicative (XMLGenT m) Source # 

Methods

pure :: a -> XMLGenT m a #

(<*>) :: XMLGenT m (a -> b) -> XMLGenT m a -> XMLGenT m b #

(*>) :: XMLGenT m a -> XMLGenT m b -> XMLGenT m b #

(<*) :: XMLGenT m a -> XMLGenT m b -> XMLGenT m a #

MonadIO m => MonadIO (XMLGenT m) Source # 

Methods

liftIO :: IO a -> XMLGenT m a #

Alternative m => Alternative (XMLGenT m) Source # 

Methods

empty :: XMLGenT m a #

(<|>) :: XMLGenT m a -> XMLGenT m a -> XMLGenT m a #

some :: XMLGenT m a -> XMLGenT m [a] #

many :: XMLGenT m a -> XMLGenT m [a] #

MonadPlus m => MonadPlus (XMLGenT m) Source # 

Methods

mzero :: XMLGenT m a #

mplus :: XMLGenT m a -> XMLGenT m a -> XMLGenT m a #

MonadCont m => MonadCont (XMLGenT m) Source # 

Methods

callCC :: ((a -> XMLGenT m b) -> XMLGenT m a) -> XMLGenT m a #

unXMLGenT :: XMLGenT m a -> m a Source #

un-lift.

mapXMLGenT :: (m a -> n b) -> XMLGenT m a -> XMLGenT n b Source #

map the inner monad

type Name a = (Maybe a, a) Source #

class Monad m => XMLGen m where Source #

Generate XML values in some XMLGenerator monad.

Minimal complete definition

genElement, xmlToChild, pcdataToChild

Associated Types

type XMLType m Source #

type StringType m Source #

data ChildType m Source #

data AttributeType m Source #

Instances

(Functor m, Monad m) => XMLGen (HSPT XML m) Source # 

Associated Types

type XMLType (HSPT XML m :: * -> *) :: * Source #

type StringType (HSPT XML m :: * -> *) :: * Source #

data ChildType (HSPT XML m :: * -> *) :: * Source #

data AttributeType (HSPT XML m :: * -> *) :: * Source #

type GenXML m = XMLGenT m (XMLType m) Source #

Type synonyms to avoid writing out the XMLnGenT all the time

class XMLGen m => EmbedAsChild m c where Source #

Embed values as child nodes of an XML element. The parent type will be clear from the context so it is not mentioned.

Minimal complete definition

asChild

Methods

asChild :: c -> GenChildList m Source #

Instances

data Attr n a Source #

Constructors

n := a 

Instances

(EmbedAsAttr m (Attr a v), TypeCastM m1 m) => EmbedAsAttr m (Attr a (XMLGenT m1 v)) Source # 

Methods

asAttr :: Attr a (XMLGenT m1 v) -> GenAttributeList m Source #

(Show n, Show a) => Show (Attr n a) Source # 

Methods

showsPrec :: Int -> Attr n a -> ShowS #

show :: Attr n a -> String #

showList :: [Attr n a] -> ShowS #

(Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text ()) Source # 
(Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text ()) Source # 
(Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text Int) Source # 
(Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text Int) Source # 
(Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text Bool) Source # 
(Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text Bool) Source # 
(Monad m, Functor m) => EmbedAsAttr (HSPT XML m) (Attr Text Char) Source # 
(Monad m, Functor m) => EmbedAsAttr (HSPT XML m) (Attr Text Char) Source # 
(Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text Text) Source # 
(Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text Text) Source # 
(Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text Text) Source # 
(Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text Text) Source # 

class XMLGen m => EmbedAsAttr m a where Source #

Similarly embed values as attributes of an XML element.

Minimal complete definition

asAttr

Methods

asAttr :: a -> GenAttributeList m Source #

Instances

EmbedAsAttr m a => EmbedAsAttr m [a] Source # 

Methods

asAttr :: [a] -> GenAttributeList m Source #

XMLGen m => EmbedAsAttr m (AttributeType m) Source # 
(EmbedAsAttr m (Attr a v), TypeCastM m1 m) => EmbedAsAttr m (Attr a (XMLGenT m1 v)) Source # 

Methods

asAttr :: Attr a (XMLGenT m1 v) -> GenAttributeList m Source #

(XMLGen m, EmbedAsAttr m a) => EmbedAsAttr m (XMLGenT m a) Source # 
(Monad m, Functor m) => EmbedAsAttr (HSPT XML m) Attribute Source # 
(Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text ()) Source # 
(Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text ()) Source # 
(Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text Int) Source # 
(Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text Int) Source # 
(Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text Bool) Source # 
(Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text Bool) Source # 
(Monad m, Functor m) => EmbedAsAttr (HSPT XML m) (Attr Text Char) Source # 
(Monad m, Functor m) => EmbedAsAttr (HSPT XML m) (Attr Text Char) Source # 
(Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text Text) Source # 
(Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text Text) Source # 
(Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text Text) Source # 
(Functor m, Monad m) => EmbedAsAttr (HSPT XML m) (Attr Text Text) Source # 

class XMLGen m => SetAttr m elem where Source #

Set attributes on XML elements

Minimal complete definition

setAll

Methods

setAttr :: elem -> GenAttribute m -> GenXML m Source #

setAll :: elem -> GenAttributeList m -> GenXML m Source #

Instances

(<@) :: (SetAttr m elem, EmbedAsAttr m attr) => elem -> attr -> GenXML m Source #

prepend attr to the list of attributes for the elem

set :: (SetAttr m elem, EmbedAsAttr m attr) => elem -> attr -> GenXML m Source #

prepend attr to the list of attributes for the elem

(<<@) :: (SetAttr m elem, EmbedAsAttr m attr) => elem -> [attr] -> GenXML m Source #

prepend the list of attr to the attributes for the elem

class XMLGen m => AppendChild m elem where Source #

Minimal complete definition

appAll

Methods

appChild :: elem -> GenChild m -> GenXML m Source #

appAll :: elem -> GenChildList m -> GenXML m Source #

Instances

(<:) :: (AppendChild m elem, EmbedAsChild m c) => elem -> c -> GenXML m Source #

append child to the children of elem

app :: (AppendChild m elem, EmbedAsChild m c) => elem -> c -> GenXML m Source #

append child to the children of elem

(<<:) :: (AppendChild m elem, EmbedAsChild m c) => elem -> [c] -> GenXML m Source #

append children to the children of elem

class Show n => IsName n s where Source #

Names can be simple or qualified with a domain. We want to conveniently use both simple strings or pairs wherever a Name is expected.

Minimal complete definition

toName

Methods

toName :: n -> Name s Source #

Instances

IsName String String Source #

Strings can represent names, meaning a simple name with no domain.

IsName String Text Source #

Strings can represent names, meaning a simple name with no domain.

Methods

toName :: String -> Name Text Source #

IsName Text Text Source #

Strings can represent names, meaning a simple name with no domain.

Methods

toName :: Text -> Name Text Source #

IsName Text Text Source #

strings can represent names, meaning a simple name with no domain.

Methods

toName :: Text -> Name Text Source #

Show a => IsName (Name a) a Source #

Names can represent names, of course.

Methods

toName :: Name a -> Name a Source #

IsName (String, String) Text Source #

Pairs of strings can represent names, meaning a name qualified with a domain.

Methods

toName :: (String, String) -> Name Text Source #

IsName (Text, Text) Text Source #

Pairs of strings can represent names, meaning a name qualified with a domain.

Methods

toName :: (Text, Text) -> Name Text Source #

IsName (Text, Text) Text Source #

Pairs of strings can represent names, meaning a name qualified with a domain.

Methods

toName :: (Text, Text) -> Name Text Source #

class TypeCast a b | a -> b, b -> a where Source #

Minimal complete definition

typeCast

Methods

typeCast :: a -> b Source #

Instances

TypeCast' () a b => TypeCast a b Source # 

Methods

typeCast :: a -> b Source #

class TypeCast' t a b | t a -> b, t b -> a where Source #

Minimal complete definition

typeCast'

Methods

typeCast' :: t -> a -> b Source #

Instances

TypeCast'' t a b => TypeCast' t a b Source # 

Methods

typeCast' :: t -> a -> b Source #

class TypeCast'' t a b | t a -> b, t b -> a where Source #

Minimal complete definition

typeCast''

Methods

typeCast'' :: t -> a -> b Source #

Instances

TypeCast'' () a a Source # 

Methods

typeCast'' :: () -> a -> a Source #

class TypeCastM ma mb | ma -> mb, mb -> ma where Source #

Minimal complete definition

typeCastM

Methods

typeCastM :: ma x -> mb x Source #

Instances

TypeCastM' () ma mb => TypeCastM ma mb Source # 

Methods

typeCastM :: ma x -> mb x Source #

class TypeCastM' t ma mb | t ma -> mb, t mb -> ma where Source #

Minimal complete definition

typeCastM'

Methods

typeCastM' :: t -> ma x -> mb x Source #

Instances

TypeCastM'' t ma mb => TypeCastM' t ma mb Source # 

Methods

typeCastM' :: t -> ma x -> mb x Source #

class TypeCastM'' t ma mb | t ma -> mb, t mb -> ma where Source #

Minimal complete definition

typeCastM''

Methods

typeCastM'' :: t -> ma x -> mb x Source #

Instances

TypeCastM'' () ma ma Source # 

Methods

typeCastM'' :: () -> ma x -> ma x Source #