{-# OPTIONS -F -pgmFtrhsx -XTypeFamilies -XOverloadedStrings -XUndecidableInstances -XOverlappingInstances -XTypeSynonymInstances -XFlexibleInstances #-} {- | Instantiation of the 'FormInput' class for the HSP package for embedding widgets within HTML-XML formatting -} module MFlow.Forms.HSP where import MFlow import MFlow.Cookies(contentHtml) import MFlow.Forms import Control.Monad.Trans import Data.Typeable import HSP.Monad import HSP.XML import HSP.XMLGenerator import Data.Monoid import Control.Monad(when) import Data.ByteString.Lazy.Char8(unpack,pack) import System.IO.Unsafe import Data.TCache.Memoization (Executable (..)) import Data.Text.Lazy.Encoding import Data.String instance (XMLGen m,XML ~ XMLType m, EmbedAsChild m(XMLType m)) => Monoid (XMLGenT m XML) where mempty = mappend x y= <% x %> <% y %> mconcat xs= <% [<% x %> | x <- xs] %> instance Typeable (XMLGenT m XML) where typeOf= \_ -> mkTyConApp(mkTyCon3 "hsp" "HSP.XMLGenerator" "XMLGenT m XML") [] instance (XMLGen m,XML ~ XMLType m ,EmbedAsChild m XML ,EmbedAsAttr m (Attr String String) ,Executable m ,SetAttr m XML) => FormInput (XMLGenT m XML) where toByteString = encodeUtf8 . renderXML . execute . unXMLGenT toHttpData = HttpData [contentHtml ] [] . toByteString ftag t = \e -> genElement (toName t) [] [asChild e] fromStr s = <% s %> fromStrNoEncode s= pcdataToChild s finput typ name value checked onclick= s ; _ -> "")/> ftextarea name text= fselect name list= foption n v msel= where selected msel = if msel then "true" else "false" :: String flink v str = <% str %> inred x= <% x %> formAction action form =
<% form %>
attrs tag attrs= tag <<@ map (\(n,v)-> n:=v) attrs