{-# OPTIONS -F -pgmFtrhsx -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 import Data.Monoid import Control.Monad(when) import Data.ByteString.Lazy.Char8(unpack,pack) import System.IO.Unsafe instance Monoid (HSP XML) where mempty = mappend x y= <% x %> <% y %> mconcat xs= <% [<% x %> | x <- xs] %> instance Typeable (HSP XML) where typeOf= \_ -> mkTyConApp(mkTyCon "HSP XML") [] instance FormInput (HSP XML) where toByteString x= unsafePerformIO $ do (_,r) <- evalHSP Nothing x return . pack $ renderXML r 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" flink v str = <% str %> inred x= <% x %> formAction action form =
<% form %>
attrs tag attrs= tag <<@ map (\(n,v)-> n:=v) attrs