WashNGo-2.12: WASH is a family of embedded domain specific languages (EDSL) for programming Web applications in Haskell.ContentsIndex
WASH.CGI.BaseCombinators
Synopsis
io :: (Read a, Show a) => IO a -> CGI a
feedback :: (CGIMonad cgi, Read a, Show a) => (a -> cgi a) -> a -> cgi a
callWithCurrentHistory :: (CGIMonad cgi, Read a, Show a) => ((a -> cgi ()) -> a -> cgi ()) -> a -> cgi ()
once :: (CGIMonad cgi, Read a, Show a) => cgi a -> cgi a
forever :: CGIMonad cgi => cgi () -> cgi ()
onceAndThen :: (CGIMonad cgi, Read a, Show a) => a -> cgi a -> cgi a
unsafe_io :: IO a -> CGI a
ask :: CGIMonad cgi => WithHTML x cgi a -> cgi ()
askResumptive :: CGIMonad cgi => WithHTML x cgi a -> cgi ()
askContinuously :: CGIMonad cgi => WithHTML x cgi a -> cgi ()
askOffline :: CGIMonad cgi => WithHTML x cgi a -> (Element -> IO ()) -> cgi ()
run :: CGI () -> IO ()
runWithOptions :: CGIOptions -> CGI () -> IO ()
runWithHook :: CGIOptions -> ([String] -> CGI ()) -> CGI () -> IO ()
makeServlet :: CGI () -> CGIProgram
makeServletWithHook :: ([String] -> CGI ()) -> CGI () -> CGIProgram
tell :: (CGIMonad cgi, CGIOutput a) => a -> cgi ()
tellContinuously :: (CGIMonad cgi, CGIOutput a) => a -> cgi ()
rawTellContinuously :: CGIOutput a => a -> CGIAction ()
htell :: CGIMonad cgi => WithHTML x IO () -> cgi a
tellError :: String -> Element -> CGIAction a
reportError :: String -> WithHTML x IO () -> CGIState -> IO (a, CGIState)
backLink :: Monad m => HTMLCons x y m ()
hlink :: Monad m => URL -> HTMLCons x y m ()
frameTranslator :: CGIMonad cgi => ([String] -> cgi ()) -> [String] -> cgi ()
docTranslator :: [FreeForm] -> ([String] -> CGI ()) -> [String] -> CGI ()
lastTranslator :: [String] -> CGI ()
subVar :: String
Documentation
io :: (Read a, Show a) => IO a -> CGI a
Safe embedding of an IO action into the CGI monad. Intentionally not parameterized óver its monad to avoid its use inside of transactions.
feedback :: (CGIMonad cgi, Read a, Show a) => (a -> cgi a) -> a -> cgi a

Runs a CGI state transformer forever. Its specification is just

 feedback f x = f x >>= feedback f

However, feedback is more efficient because it avoids the buildup of long interaction logs by cutting back every time just before f is invoked. Unfortunately, it's useless due to typing restrictions.

callWithCurrentHistory :: (CGIMonad cgi, Read a, Show a) => ((a -> cgi ()) -> a -> cgi ()) -> a -> cgi ()

Control operator for the CGI monad. Its specification is

 callWithCurrentHistory (\backto x -> action x >>= backto) x
 ==
 action x >>= callWithCurrentHistory (\backto x -> action x >>= backto)

However, callWithCurrentHistory is more efficient because it avoids the buildup of long interaction logs by cutting back every time just before action gets executed.

once :: (CGIMonad cgi, Read a, Show a) => cgi a -> cgi a
Brackets a CGI action so that only its result is visible. Improves efficiency by not executing the bracketed action after it has been performed once. Use this for avoiding the inefficient buildup of long interaction logs.
forever :: CGIMonad cgi => cgi () -> cgi ()
Repeats a CGI action without saving its state so that the size of the interaction log remains constant.
onceAndThen :: (CGIMonad cgi, Read a, Show a) => a -> cgi a -> cgi a
Unsafe variant of once: returns the computed value only the first time and returns a default value in all later invocations. [deprecated]
unsafe_io :: IO a -> CGI a
Directly lifts the IO monad into the CGI monad. This is generally unsafe and should be avoided. Use io instead.
ask :: CGIMonad cgi => WithHTML x cgi a -> cgi ()
Takes a monadic value that constructs a HTML page and delivers this page to the browser. This page may contain forms and input widgets.
askResumptive :: CGIMonad cgi => WithHTML x cgi a -> cgi ()
Implementation of ask for the pure logged variant.
askContinuously :: CGIMonad cgi => WithHTML x cgi a -> cgi ()
Experimental implementation of continuous version.
askOffline :: CGIMonad cgi => WithHTML x cgi a -> (Element -> IO ()) -> cgi ()
Like ask, but passes the constructed HTML page to the elementAction parameter. This function may send the page via Email or store it into a file. Anyone loading this page in a browser can resume the interaction.
run :: CGI () -> IO ()

Turns a CGI action into an IO action. Used to turn the main CGI action into the main function of the program. Typical use:

 main = run mainCGI
runWithOptions :: CGIOptions -> CGI () -> IO ()

Turns a CGI action into an IO action. Used to turn the main CGI action into the main function of the program. Takes additional low-level options. Typical use:

 main = runWithOptions [] mainCGI
runWithHook :: CGIOptions -> ([String] -> CGI ()) -> CGI () -> IO ()
Variant of run where an additional argument cgigen specifies an action taken when the script is invoked with a non-empty query string as in script-name?query-string
makeServlet :: CGI () -> CGIProgram
Transform a CGI action into a servlet suitable for running from Marlow's web server.
makeServletWithHook :: ([String] -> CGI ()) -> CGI () -> CGIProgram
Like makeServlet with additional CGI generator as in runWithHook.
tell :: (CGIMonad cgi, CGIOutput a) => a -> cgi ()
Terminates script by sending its argument to the browser.
tellContinuously :: (CGIMonad cgi, CGIOutput a) => a -> cgi ()
(experimental: continuous version) send argument to the browser.
rawTellContinuously :: CGIOutput a => a -> CGIAction ()
htell :: CGIMonad cgi => WithHTML x IO () -> cgi a
Terminate script by sending a HTML page constructed by monadic argument.
tellError :: String -> Element -> CGIAction a
reportError :: String -> WithHTML x IO () -> CGIState -> IO (a, CGIState)
backLink :: Monad m => HTMLCons x y m ()
Link to previous page in browser's history. Uses JavaScript.
hlink :: Monad m => URL -> HTMLCons x y m ()
Plain Hyperlink from an URL string.
frameTranslator :: CGIMonad cgi => ([String] -> cgi ()) -> [String] -> cgi ()
docTranslator :: [FreeForm] -> ([String] -> CGI ()) -> [String] -> CGI ()
A translator is a function [String] -> CGI (). It takes the query string of the URL (of type [String]) and translates it into a CGI action. docTranslator docs next takes a list of FreeForm documents and a next translator. It tries to select a document by its ffName and falls through to the next translator if no document matches.
lastTranslator :: [String] -> CGI ()
Terminates a sequence of translators.
subVar :: String
Internal: name for the submission variable and form field
Produced by Haddock version 0.8