Module HTML.Base

Library for constructing static and dynamic HTML pages. This paper contains a description of the basic ideas behind this library.

A cgi script written with this library can be installed by the command

cypm exec curry2cgi -m mainPage -o /home/joe/public_html/prog.cgi Prog

where Prog is the name of the Curry program with the cgi script, /home/joe/public_html/prog.cgi is the desired location of the compiled cgi script, and mainPage is the Curry expression (of type IO HtmlPage) computing the HTML page (where cypm is the command calling the Curry Package Manager).

Author: Michael Hanus (with extensions by Bernd Brassel and Marco Comini)

Version: August 2020

Summary of exported operations:

defaultEncoding :: String   
The default encoding used in generated web pages.
idOfCgiRef :: CgiRef -> String   
Internal identifier of a CgiRef (intended only for internal use in other libraries!).
textOf :: [HtmlExp] -> String   
Extracts the textual contents of a list of HTML expressions.
formDef :: IO a -> (a -> [HtmlExp]) -> HtmlFormDef a   
A definition of a form which consists of a (reading!) IO action and a mapping from data into an HTML expression (which usually contains event handlers to produce the form answers).
formDefWithID :: String -> IO a -> (a -> [HtmlExp]) -> HtmlFormDef a   
A definition of a form with a unique identifier (usually, the qualified name of the operation defining the form).
formDefId :: HtmlFormDef a -> String   
Returns the identifier of a form definition.
setFormDefId :: String -> HtmlFormDef a -> HtmlFormDef a   
Sets the identifier of a form definition.
formDefRead :: HtmlFormDef a -> IO a   
Returns the read action of a form definition.
formDefView :: HtmlFormDef a -> a -> [HtmlExp]   
Returns the read action of a form definition.
instCgiRefs :: [HtmlExp] -> Int -> ([HtmlExp],Int)   
Instantiates all CgiRefs with a unique tag in HTML expressions.
pageEnc :: String -> PageParam   
An encoding scheme for a HTML page.
pageCookie :: (String,String) -> PageParam   
A cookie to be sent to the client's browser when a HTML page is requested.
pageCSS :: String -> PageParam   
A URL for a CSS file for a HTML page.
pageMetaInfo :: [(String,String)] -> PageParam   
Meta information for a HTML page.
pageLinkInfo :: [(String,String)] -> PageParam   
Link information for a HTML page.
pageBodyAttr :: (String,String) -> PageParam   
Optional attribute for the body element of the web page.
page :: String -> [HtmlExp] -> HtmlPage   
A basic HTML web page with the default encoding.
standardPage :: String -> [HtmlExp] -> HtmlPage   
A standard HTML web page where the title is included in the body as the first header.
addPageParam :: HtmlPage -> PageParam -> HtmlPage   
Adds a parameter to an HTML page.
addCookies :: [(String,String)] -> HtmlPage -> HtmlPage   
Add simple cookie to an HTML page.
addHttpHeader :: String -> String -> HtmlPage -> HtmlPage   
Add a HTTP header to a HTML page.
formatCookie :: (String,String,[CookieParam]) -> String   
answerText :: String -> HtmlPage   
A textual result instead of an HTML page as a result for active web pages.
answerEncText :: String -> String -> HtmlPage   
A textual result instead of an HTML page as a result for active web pages where the encoding is given as the first parameter.
redirectPage :: String -> HtmlPage   
Generates a redirection page to a given URL.
expires :: Int -> HtmlPage -> HtmlPage   
Adds expire time to given HTML page.
htxt :: String -> HtmlExp   
Basic text as HTML expression.
htxts :: [String] -> [HtmlExp]   
A list of strings represented as a list of HTML expressions.
hempty :: HtmlExp   
An empty HTML expression.
nbsp :: HtmlExp   
Non breaking Space
h1 :: [HtmlExp] -> HtmlExp   
Header 1
h2 :: [HtmlExp] -> HtmlExp   
Header 2
h3 :: [HtmlExp] -> HtmlExp   
Header 3
h4 :: [HtmlExp] -> HtmlExp   
Header 4
h5 :: [HtmlExp] -> HtmlExp   
Header 5
h6 :: [HtmlExp] -> HtmlExp   
Header 6
par :: [HtmlExp] -> HtmlExp   
Paragraph
section :: [HtmlExp] -> HtmlExp   
Section
header :: [HtmlExp] -> HtmlExp   
Header
footer :: [HtmlExp] -> HtmlExp   
Footer
emphasize :: [HtmlExp] -> HtmlExp   
Emphasize
strong :: [HtmlExp] -> HtmlExp   
Strong (more emphasized) text.
bold :: [HtmlExp] -> HtmlExp   
Boldface
italic :: [HtmlExp] -> HtmlExp   
Italic
nav :: [HtmlExp] -> HtmlExp   
Navigation
code :: [HtmlExp] -> HtmlExp   
Program code
center :: [HtmlExp] -> HtmlExp   
Centered text
blink :: [HtmlExp] -> HtmlExp   
Blinking text
teletype :: [HtmlExp] -> HtmlExp   
Teletype font
pre :: [HtmlExp] -> HtmlExp   
Unformatted input, i.e., keep spaces and line breaks and don't quote special characters.
verbatim :: String -> HtmlExp   
Verbatim (unformatted), special characters (<,>,&,") are quoted.
address :: [HtmlExp] -> HtmlExp   
Address
href :: String -> [HtmlExp] -> HtmlExp   
Hypertext reference
anchor :: String -> [HtmlExp] -> HtmlExp   
An anchored text with a hypertext reference inside a document.
ulist :: [[HtmlExp]] -> HtmlExp   
Unordered list.
ulistWithClass :: String -> String -> [[HtmlExp]] -> HtmlExp   
An unordered list with classes for the entire list and the list elements.
ulistWithItemClass :: String -> [(String,[HtmlExp])] -> HtmlExp   
An unordered list with classes for the entire list individual classes for the list elements.
olist :: [[HtmlExp]] -> HtmlExp   
Ordered list.
olistWithClass :: String -> String -> [[HtmlExp]] -> HtmlExp   
An ordered list with classes for the entire list and the list elements.
olistWithItemClass :: String -> [(String,[HtmlExp])] -> HtmlExp   
An ordered list with classes for the entire list individual classes for the list elements.
litem :: [HtmlExp] -> HtmlExp   
A single list item (usually not explicitly used)
dlist :: [([HtmlExp],[HtmlExp])] -> HtmlExp   
Description list
table :: [[[HtmlExp]]] -> HtmlExp   
Table with a matrix of items where each item is a list of HTML expressions.
tableWithClass :: String -> String -> String -> [[[HtmlExp]]] -> HtmlExp   
Table with a matrix of items (each item is a list of HTML expressions) with classes for the entire table, each row, and each data element.
headedTable :: [[[HtmlExp]]] -> HtmlExp   
Similar to table but introduces header tags for the first row.
addHeadings :: HtmlExp -> [[HtmlExp]] -> HtmlExp   
Add a row of items (where each item is a list of HTML expressions) as headings to a table.
hrule :: HtmlExp   
Horizontal rule
breakline :: HtmlExp   
Break a line
image :: String -> String -> HtmlExp   
Image
styleSheet :: String -> HtmlExp   
Defines a style sheet to be used in this HTML document.
style :: String -> [HtmlExp] -> HtmlExp   
Provides a style for HTML elements.
textstyle :: String -> String -> HtmlExp   
Provides a style for a basic text.
blockstyle :: String -> [HtmlExp] -> HtmlExp   
Provides a style for a block of HTML elements.
inline :: [HtmlExp] -> HtmlExp   
Joins a list of HTML elements into a single HTML element.
block :: [HtmlExp] -> HtmlExp   
Joins a list of HTML elements into a block.
formExp :: HtmlFormDef a -> HtmlExp   
A form embedded in an HTML expression.
button :: String -> ((CgiRef -> String) -> IO HtmlPage) -> HtmlExp   
A button to submit a form with a label string and an event handler.
resetButton :: String -> HtmlExp   
Reset button with a label string
imageButton :: String -> ((CgiRef -> String) -> IO HtmlPage) -> HtmlExp   
Submit button in form of an imag.
textField :: CgiRef -> String -> HtmlExp   
Input text field with a reference and an initial contents
password :: CgiRef -> HtmlExp   
Input text field (where the entered text is obscured) with a reference
textArea :: CgiRef -> (Int,Int) -> String -> HtmlExp   
Input text area with a reference, height/width, and initial contents
checkBox :: CgiRef -> String -> HtmlExp   
A checkbox with a reference and a value.
checkedBox :: CgiRef -> String -> HtmlExp   
A checkbox that is initially checked with a reference and a value.
radioMain :: CgiRef -> String -> HtmlExp   
A main button of a radio (initially "on") with a reference and a value.
radioMainOff :: CgiRef -> String -> HtmlExp   
A main button of a radio (initially "off") with a reference and a value.
radioOther :: CgiRef -> String -> HtmlExp   
A further button of a radio (initially "off") with a reference (identical to the main button of this radio) and a value.
selection :: CgiRef -> [(String,String)] -> HtmlExp   
A selection button with a reference and a list of name/value pairs.
selectionInitial :: CgiRef -> [(String,String)] -> Int -> HtmlExp   
A selection button with a reference, a list of name/value pairs, and a preselected item in this list.
multipleSelection :: CgiRef -> [(String,String,Bool)] -> HtmlExp   
A selection button with a reference and a list of name/value/flag pairs.
hiddenField :: String -> String -> HtmlExp   
A hidden field to pass a value referenced by a fixed name.
htmlQuote :: String -> String   
Quotes special characters (<,>,&,", umlauts) in a string as HTML special characters.
htmlIsoUmlauts :: String -> String   
Translates umlauts in iso-8859-1 encoding into HTML special characters.
addAttr :: HtmlExp -> (String,String) -> HtmlExp   
Adds an attribute (name/value pair) to an HTML element.
addAttrs :: HtmlExp -> [(String,String)] -> HtmlExp   
Adds a list of attributes (name/value pair) to an HTML element.
addClass :: HtmlExp -> String -> HtmlExp   
Adds a class attribute to an HTML element (if the class attribute is not empty).
showHtmlExps :: [HtmlExp] -> String   
Transforms a list of HTML expressions into string representation.
showHtmlExp :: HtmlExp -> String   
Transforms a single HTML expression into string representation.
showHtmlPage :: HtmlPage -> String   
Transforms HTML page into string representation.
htmlPrelude :: String   
Standard header for generated HTML pages.
htmlTagAttrs :: [(String,String)]   
Standard attributes for element "html".
getUrlParameter :: IO String   
Gets the parameter attached to the URL of the script.
urlencoded2string :: String -> String   
Translates urlencoded string into equivalent ASCII string.
string2urlencoded :: String -> String   
Translates arbitrary strings into equivalent urlencoded string.
getCookies :: IO [(String,String)]   
Gets the cookies sent from the browser for the current CGI script.
coordinates :: (CgiRef -> String) -> Maybe (Int,Int)   
For image buttons: retrieve the coordinates where the user clicked within the image.

Exported datatypes:


CgiRef

The (abstract) data type for representing references to input elements in HTML forms.

Constructors:


CgiEnv

The type for representing cgi environments (i.e., mappings from cgi references to the corresponding values of the input elements).

Type synonym: CgiEnv = CgiRef -> String


HtmlHandler

The type of event handlers occurring in HTML forms.

Type synonym: HtmlHandler = CgiEnv -> IO HtmlPage


HtmlExp

The data type for representing HTML expressions.

Constructors:

  • HtmlText :: String -> HtmlExp : a text string without any further structure
  • HtmlStruct :: String -> [(String,String)] -> [HtmlExp] -> HtmlExp : a structure with a tag, attributes, and HTML expressions inside the structure
  • HtmlCRef :: HtmlExp -> CgiRef -> HtmlExp : an input element (described by the first argument) with a cgi reference
  • HtmlEvent :: HtmlExp -> CgiRef -> HtmlHandler -> HtmlExp : an input element (first arg) identified by a cgi reference with an associated event handler (typically, a submit button)
  • HtmlAction :: (IO HtmlExp) -> HtmlExp : an action that computes an HTML expression which will be inserted when the HTML document is shown

HtmlFormDef

The data type for representing HTML forms embedded into HTML pages.

A form definition consists of a unique identifier of form (usually, the qualified name of the operation defining the form), a (reading!) IO action and a mapping from data into an HTML expression (which usually contains event handlers to produce the form answers). It is assumed that the IO action reads only data and does not change it, since it is applied twice when executing a form.

Constructors:


HtmlPage

The data type for representing HTML pages.

Constructors:

  • HtmlPage :: String -> [PageParam] -> [HtmlExp] -> HtmlPage : an HTML page with title t, optional parameters (e.g., cookies) ps, and contents hs
  • HtmlAnswer :: String -> String -> HtmlPage : an answer in an arbitrary format where t is the content type (e.g., "text/plain") and c is the contents

PageParam

The possible parameters of an HTML page. The parameters of a cookie (PageCookie) are its name and value and optional parameters (expiration date, domain, path (e.g., the path "/" makes the cookie valid for all documents on the server), security) which are collected in a list.

Constructors:

  • PageEnc :: String -> PageParam : the encoding scheme of this page
  • PageCookie :: String -> String -> [CookieParam] -> PageParam : a cookie to be sent to the client's browser
  • PageCSS :: String -> PageParam : a URL for a CSS file for this page
  • HttpHeader :: String -> String -> PageParam : additional HTTP header included in this page
  • PageJScript :: String -> PageParam : a URL for a Javascript file for this page
  • PageMeta :: [(String,String)] -> PageParam : meta information (in form of attributes) for this page
  • PageLink :: [(String,String)] -> PageParam : link information (in form of attributes) for this page
  • PageHeadInclude :: HtmlExp -> PageParam : HTML expression to be included in page header
  • PageBodyAttr :: (String,String) -> PageParam : optional attribute for the body element of the page (more than one occurrence is allowed)

CookieParam

The possible parameters of a cookie.

Constructors:

  • CookieExpire :: ClockTime -> CookieParam
  • CookieDomain :: String -> CookieParam
  • CookiePath :: String -> CookieParam
  • CookieSecure :: CookieParam

Exported operations:

defaultEncoding :: String   

The default encoding used in generated web pages.

Further infos:
  • solution complete, i.e., able to compute all solutions

idOfCgiRef :: CgiRef -> String   

Internal identifier of a CgiRef (intended only for internal use in other libraries!).

Further infos:
  • solution complete, i.e., able to compute all solutions

textOf :: [HtmlExp] -> String   

Extracts the textual contents of a list of HTML expressions. For instance,

textOf [HtmlText "xy", HtmlStruct "a" [] [HtmlText "bc"]] == "xy bc"

formDef :: IO a -> (a -> [HtmlExp]) -> HtmlFormDef a   

A definition of a form which consists of a (reading!) IO action and a mapping from data into an HTML expression (which usually contains event handlers to produce the form answers). It is assumed that the IO action reads only data and does not change it, since it is applied twice when executing a form.

The unique identifier required for the implementation of forms is added by the curry2cgi translator.

Further infos:
  • solution complete, i.e., able to compute all solutions

formDefWithID :: String -> IO a -> (a -> [HtmlExp]) -> HtmlFormDef a   

A definition of a form with a unique identifier (usually, the qualified name of the operation defining the form). A form contains a (reading!) IO action and a mapping from data into an HTML expression (which usually contains event handlers to produce the form answers). It is assumed that the IO action reads only data and does not change it, since it is applied twice when executing a form.

Further infos:
  • solution complete, i.e., able to compute all solutions

formDefId :: HtmlFormDef a -> String   

Returns the identifier of a form definition.

Further infos:
  • solution complete, i.e., able to compute all solutions

setFormDefId :: String -> HtmlFormDef a -> HtmlFormDef a   

Sets the identifier of a form definition. Only intended for internal use in the curry2cgi translator.

Further infos:
  • solution complete, i.e., able to compute all solutions

formDefRead :: HtmlFormDef a -> IO a   

Returns the read action of a form definition.

Further infos:
  • solution complete, i.e., able to compute all solutions

formDefView :: HtmlFormDef a -> a -> [HtmlExp]   

Returns the read action of a form definition.

Further infos:
  • solution complete, i.e., able to compute all solutions

instCgiRefs :: [HtmlExp] -> Int -> ([HtmlExp],Int)   

Instantiates all CgiRefs with a unique tag in HTML expressions. Only internally used.

Further infos:
  • partially defined

pageEnc :: String -> PageParam   

An encoding scheme for a HTML page.

Further infos:
  • solution complete, i.e., able to compute all solutions

pageCSS :: String -> PageParam   

A URL for a CSS file for a HTML page.

Further infos:
  • solution complete, i.e., able to compute all solutions

pageMetaInfo :: [(String,String)] -> PageParam   

Meta information for a HTML page. The argument is a list of attributes included in the meta-tag in the header for this page.

Further infos:
  • solution complete, i.e., able to compute all solutions

pageLinkInfo :: [(String,String)] -> PageParam   

Link information for a HTML page. The argument is a list of attributes included in the link-tag in the header for this page.

Further infos:
  • solution complete, i.e., able to compute all solutions

pageBodyAttr :: (String,String) -> PageParam   

Optional attribute for the body element of the web page. More than one occurrence is allowed, i.e., all such attributes are collected.

Further infos:
  • solution complete, i.e., able to compute all solutions

page :: String -> [HtmlExp] -> HtmlPage   

A basic HTML web page with the default encoding.

Example call:
(page title hexps)
Parameters:
  • title : the title of the page
  • hexps : the page's body (list of HTML expressions)
Returns:
an HTML page
Further infos:
  • solution complete, i.e., able to compute all solutions

standardPage :: String -> [HtmlExp] -> HtmlPage   

A standard HTML web page where the title is included in the body as the first header.

Example call:
(standardPage title hexps)
Parameters:
  • title : the title of the page
  • hexps : the page's body (list of HTML expressions)
Returns:
an HTML page with the title as the first header

addPageParam :: HtmlPage -> PageParam -> HtmlPage   

Adds a parameter to an HTML page.

Example call:
(addPageParam page param)
Parameters:
  • page : a page
  • param : a page's parameter
Returns:
an HTML page
Further infos:
  • defined as left-associative infix operator with precedence 0
  • solution complete, i.e., able to compute all solutions

addCookies :: [(String,String)] -> HtmlPage -> HtmlPage   

Add simple cookie to an HTML page. The cookies are sent to the client's browser together with this page.

Example call:
(addCookies cs form)
Parameters:
  • cs : the cookies as a list of name/value pairs
  • form : the form to add cookies to
Returns:
a new HTML page

addHttpHeader :: String -> String -> HtmlPage -> HtmlPage   

Add a HTTP header to a HTML page. Headers are sent to the client's browser together with the page.

Example call:
(addHttpHeader key value page)
Parameters:
  • key : the name of the HTTP header field
  • value : the value of the HTTP header field
  • page : the page to which the header is added
Returns:
a new HTML page

formatCookie :: (String,String,[CookieParam]) -> String   

answerText :: String -> HtmlPage   

A textual result instead of an HTML page as a result for active web pages.

Example call:
(answerText txt)
Parameters:
  • txt : the contents of the result page
Returns:
an HTML answer page
Further infos:
  • solution complete, i.e., able to compute all solutions

answerEncText :: String -> String -> HtmlPage   

A textual result instead of an HTML page as a result for active web pages where the encoding is given as the first parameter.

Example call:
(answerEncText enc txt)
Parameters:
  • enc : the encoding of the text(e.g., "utf-8" or "iso-8859-1")
  • txt : the contents of the result page
Returns:
an HTML answer page
Further infos:
  • solution complete, i.e., able to compute all solutions

redirectPage :: String -> HtmlPage   

Generates a redirection page to a given URL. This is implemented via the HTTP response header Location (see also https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Location).

Example call:
(redirectPage url page)
Parameters:
  • url : The URL target of the redirection
  • page : The redirection page

expires :: Int -> HtmlPage -> HtmlPage   

Adds expire time to given HTML page.

Example call:
(expires secs page)
Parameters:
  • secs : Number of seconds before document expires
  • page : The page to add the header information to

htxt :: String -> HtmlExp   

Basic text as HTML expression. The text may contain special HTML chars (like <,>,&,") which will be quoted so that they appear as in the parameter string.

htxts :: [String] -> [HtmlExp]   

A list of strings represented as a list of HTML expressions. The strings may contain special HTML chars that will be quoted.

hempty :: HtmlExp   

An empty HTML expression.

Further infos:
  • solution complete, i.e., able to compute all solutions

nbsp :: HtmlExp   

Non breaking Space

Further infos:
  • solution complete, i.e., able to compute all solutions

h1 :: [HtmlExp] -> HtmlExp   

Header 1

Further infos:
  • solution complete, i.e., able to compute all solutions

h2 :: [HtmlExp] -> HtmlExp   

Header 2

Further infos:
  • solution complete, i.e., able to compute all solutions

h3 :: [HtmlExp] -> HtmlExp   

Header 3

Further infos:
  • solution complete, i.e., able to compute all solutions

h4 :: [HtmlExp] -> HtmlExp   

Header 4

Further infos:
  • solution complete, i.e., able to compute all solutions

h5 :: [HtmlExp] -> HtmlExp   

Header 5

Further infos:
  • solution complete, i.e., able to compute all solutions

h6 :: [HtmlExp] -> HtmlExp   

Header 6

Further infos:
  • solution complete, i.e., able to compute all solutions

par :: [HtmlExp] -> HtmlExp   

Paragraph

Further infos:
  • solution complete, i.e., able to compute all solutions

section :: [HtmlExp] -> HtmlExp   

Section

Further infos:
  • solution complete, i.e., able to compute all solutions

emphasize :: [HtmlExp] -> HtmlExp   

Emphasize

Further infos:
  • solution complete, i.e., able to compute all solutions

strong :: [HtmlExp] -> HtmlExp   

Strong (more emphasized) text.

Further infos:
  • solution complete, i.e., able to compute all solutions

bold :: [HtmlExp] -> HtmlExp   

Boldface

Further infos:
  • solution complete, i.e., able to compute all solutions

italic :: [HtmlExp] -> HtmlExp   

Italic

Further infos:
  • solution complete, i.e., able to compute all solutions

code :: [HtmlExp] -> HtmlExp   

Program code

Further infos:
  • solution complete, i.e., able to compute all solutions

center :: [HtmlExp] -> HtmlExp   

Centered text

Further infos:
  • solution complete, i.e., able to compute all solutions

teletype :: [HtmlExp] -> HtmlExp   

Teletype font

Further infos:
  • solution complete, i.e., able to compute all solutions

pre :: [HtmlExp] -> HtmlExp   

Unformatted input, i.e., keep spaces and line breaks and don't quote special characters.

Further infos:
  • solution complete, i.e., able to compute all solutions

verbatim :: String -> HtmlExp   

Verbatim (unformatted), special characters (<,>,&,") are quoted.

address :: [HtmlExp] -> HtmlExp   

Address

Further infos:
  • solution complete, i.e., able to compute all solutions

href :: String -> [HtmlExp] -> HtmlExp   

Hypertext reference

Further infos:
  • solution complete, i.e., able to compute all solutions

anchor :: String -> [HtmlExp] -> HtmlExp   

An anchored text with a hypertext reference inside a document.

Further infos:
  • solution complete, i.e., able to compute all solutions

ulist :: [[HtmlExp]] -> HtmlExp   

Unordered list.

Example call:
(ulist items)
Parameters:
  • items : the list items where each item is a list of HTML expressions

ulistWithClass :: String -> String -> [[HtmlExp]] -> HtmlExp   

An unordered list with classes for the entire list and the list elements. The class annotation will be ignored if it is empty.

Example call:
(ulistWithClass listclass itemclass items)
Parameters:
  • listclass : the class for the entire list structure
  • itemclass : the class for the list items
  • items : the list items where each item is a list of HTML expressions

ulistWithItemClass :: String -> [(String,[HtmlExp])] -> HtmlExp   

An unordered list with classes for the entire list individual classes for the list elements. The class annotation will be ignored if it is empty.

Example call:
(ulistWithItemClass listclass classitems)
Parameters:
  • listclass : the class for the entire list structure
  • classitems : the list items together with their classes

olist :: [[HtmlExp]] -> HtmlExp   

Ordered list.

Example call:
(olist items)
Parameters:
  • items : the list items where each item is a list of HTML expressions

olistWithClass :: String -> String -> [[HtmlExp]] -> HtmlExp   

An ordered list with classes for the entire list and the list elements. The class annotation will be ignored if it is empty.

Example call:
(olistWithClass listclass itemclass items)
Parameters:
  • listclass : the class for the entire list structure
  • itemclass : the class for the list items
  • items : the list items where each item is a list of HTML expressions

olistWithItemClass :: String -> [(String,[HtmlExp])] -> HtmlExp   

An ordered list with classes for the entire list individual classes for the list elements. The class annotation will be ignored if it is empty.

Example call:
(olistWithItemClass listclass classitems)
Parameters:
  • listclass : the class for the entire list structure
  • classitems : the list items together with their classes

litem :: [HtmlExp] -> HtmlExp   

A single list item (usually not explicitly used)

Further infos:
  • solution complete, i.e., able to compute all solutions

dlist :: [([HtmlExp],[HtmlExp])] -> HtmlExp   

Description list

Example call:
(dlist items)
Parameters:
  • items : a list of (title/description) pairs (of HTML expressions)

table :: [[[HtmlExp]]] -> HtmlExp   

Table with a matrix of items where each item is a list of HTML expressions.

tableWithClass :: String -> String -> String -> [[[HtmlExp]]] -> HtmlExp   

Table with a matrix of items (each item is a list of HTML expressions) with classes for the entire table, each row, and each data element. The class annotation will be ignored if it is empty.

Example call:
(tableWithClass tableclass rowclass dataclass items)
Parameters:
  • tableclass : the class for the entire table structure
  • rowclass : the class for the table rows
  • dataclass : the class for the table data items
  • items : the matrix of table items where each item is a list of HTML expressions

headedTable :: [[[HtmlExp]]] -> HtmlExp   

Similar to table but introduces header tags for the first row.

addHeadings :: HtmlExp -> [[HtmlExp]] -> HtmlExp   

Add a row of items (where each item is a list of HTML expressions) as headings to a table. If the first argument is not a table, the headings are ignored.

hrule :: HtmlExp   

Horizontal rule

Further infos:
  • solution complete, i.e., able to compute all solutions

breakline :: HtmlExp   

Break a line

Further infos:
  • solution complete, i.e., able to compute all solutions

image :: String -> String -> HtmlExp   

Image

Example call:
(image src alt)
Parameters:
  • src : the URL of the image
  • alt : the alternative text shown instead of the image

styleSheet :: String -> HtmlExp   

Defines a style sheet to be used in this HTML document.

Example call:
(styleSheet css)
Parameters:
  • css : a string in CSS format
Further infos:
  • solution complete, i.e., able to compute all solutions

style :: String -> [HtmlExp] -> HtmlExp   

Provides a style for HTML elements. The style argument is the name of a style class defined in a style definition (see styleSheet) or in an external style sheet (see form and page parameters FormCSS and PageCSS).

Example call:
(style st hexps)
Parameters:
  • st : name of a style class
  • hexps : list of HTML expressions
Further infos:
  • solution complete, i.e., able to compute all solutions

textstyle :: String -> String -> HtmlExp   

Provides a style for a basic text. The style argument is the name of a style class defined in an external style sheet.

Example call:
(textstyle st txt)
Parameters:
  • st : name of a style class
  • txt : a string (special characters will be quoted)

blockstyle :: String -> [HtmlExp] -> HtmlExp   

Provides a style for a block of HTML elements. The style argument is the name of a style class defined in an external style sheet. This element is used (in contrast to "style") for larger blocks of HTML elements since a line break is placed before and after these elements.

Example call:
(blockstyle st hexps)
Parameters:
  • st : name of a style class
  • hexps : list of HTML expressions
Further infos:
  • solution complete, i.e., able to compute all solutions

inline :: [HtmlExp] -> HtmlExp   

Joins a list of HTML elements into a single HTML element. Although this construction has no rendering, it is sometimes useful for programming when several HTML elements must be put together.

Example call:
(inline hexps)
Parameters:
  • hexps : list of HTML expressions
Further infos:
  • solution complete, i.e., able to compute all solutions

block :: [HtmlExp] -> HtmlExp   

Joins a list of HTML elements into a block. A line break is placed before and after these elements.

Example call:
(block hexps)
Parameters:
  • hexps : list of HTML expressions
Further infos:
  • solution complete, i.e., able to compute all solutions

formExp :: HtmlFormDef a -> HtmlExp   

A form embedded in an HTML expression. The parameter is a form defined as an exported top-level operation in the CGI program so that it can be accessed by the main program. The URL of the generated form is the same as the main page, i.e., the current URL parameter is passed to the form (which is useful for REST-based programming with URL parameters). The form uses a hidden field named FORMID to identify the form in the submitted form controller.

button :: String -> ((CgiRef -> String) -> IO HtmlPage) -> HtmlExp   

A button to submit a form with a label string and an event handler.

resetButton :: String -> HtmlExp   

Reset button with a label string

imageButton :: String -> ((CgiRef -> String) -> IO HtmlPage) -> HtmlExp   

Submit button in form of an imag.

Example call:
(imageButton src handler)
Parameters:
  • src : url of the image
  • handler : event handler

textField :: CgiRef -> String -> HtmlExp   

Input text field with a reference and an initial contents

password :: CgiRef -> HtmlExp   

Input text field (where the entered text is obscured) with a reference

textArea :: CgiRef -> (Int,Int) -> String -> HtmlExp   

Input text area with a reference, height/width, and initial contents

checkBox :: CgiRef -> String -> HtmlExp   

A checkbox with a reference and a value. The value is returned if checkbox is on, otherwise "" is returned.

checkedBox :: CgiRef -> String -> HtmlExp   

A checkbox that is initially checked with a reference and a value. The value is returned if checkbox is on, otherwise "" is returned.

radioMain :: CgiRef -> String -> HtmlExp   

A main button of a radio (initially "on") with a reference and a value. The value is returned of this button is on. A complete radio button suite always consists of a main button (radiomain) and some further buttons (radioothers) with the same reference. Initially, the main button is selected (or nothing is selected if one uses radiomainoff instead of radio_main). The user can select another button but always at most one button of the radio can be selected. The value corresponding to the selected button is returned in the environment for this radio reference.

radioMainOff :: CgiRef -> String -> HtmlExp   

A main button of a radio (initially "off") with a reference and a value. The value is returned of this button is on.

radioOther :: CgiRef -> String -> HtmlExp   

A further button of a radio (initially "off") with a reference (identical to the main button of this radio) and a value. The value is returned of this button is on.

selection :: CgiRef -> [(String,String)] -> HtmlExp   

A selection button with a reference and a list of name/value pairs. The names are shown in the selection and the value is returned for the selected name.

selectionInitial :: CgiRef -> [(String,String)] -> Int -> HtmlExp   

A selection button with a reference, a list of name/value pairs, and a preselected item in this list. The names are shown in the selection and the value is returned for the selected name.

Example call:
(selectionInitial ref nvs sel)
Parameters:
  • ref : a CGI reference
  • nvs : list of name/value pairs
  • sel : the index of the initially selected item in the list nvs
Returns:
an HTML expression representing the selection button

multipleSelection :: CgiRef -> [(String,String,Bool)] -> HtmlExp   

A selection button with a reference and a list of name/value/flag pairs. The names are shown in the selection and the value is returned if the corresponding name is selected. If flag is True, the corresonding name is initially selected. If more than one name has been selected, all values are returned in one string where the values are separated by newline (<code><a href="#\n">\n</a></code>) characters.

hiddenField :: String -> String -> HtmlExp   

A hidden field to pass a value referenced by a fixed name. This function should be used with care since it may cause conflicts with the CGI-based implementation of this library.

Further infos:
  • solution complete, i.e., able to compute all solutions

htmlQuote :: String -> String   

Quotes special characters (<,>,&,", umlauts) in a string as HTML special characters.

htmlIsoUmlauts :: String -> String   

Translates umlauts in iso-8859-1 encoding into HTML special characters.

addAttr :: HtmlExp -> (String,String) -> HtmlExp   

Adds an attribute (name/value pair) to an HTML element.

Further infos:
  • defined as left-associative infix operator with precedence 0
  • solution complete, i.e., able to compute all solutions

addAttrs :: HtmlExp -> [(String,String)] -> HtmlExp   

Adds a list of attributes (name/value pair) to an HTML element.

Further infos:
  • defined as left-associative infix operator with precedence 0
  • solution complete, i.e., able to compute all solutions

addClass :: HtmlExp -> String -> HtmlExp   

Adds a class attribute to an HTML element (if the class attribute is not empty).

Further infos:
  • defined as left-associative infix operator with precedence 0

showHtmlExps :: [HtmlExp] -> String   

Transforms a list of HTML expressions into string representation.

showHtmlExp :: HtmlExp -> String   

Transforms a single HTML expression into string representation.

showHtmlPage :: HtmlPage -> String   

Transforms HTML page into string representation.

Example call:
(showHtmlPage page)
Parameters:
  • page : the HTML page
Returns:
string representation of the HTML document

htmlPrelude :: String   

Standard header for generated HTML pages.

Further infos:
  • solution complete, i.e., able to compute all solutions

htmlTagAttrs :: [(String,String)]   

Standard attributes for element "html".

Further infos:
  • solution complete, i.e., able to compute all solutions

getUrlParameter :: IO String   

Gets the parameter attached to the URL of the script. For instance, if the script is called with URL "http://.../script.cgi?parameter", then "parameter" is returned by this I/O action. Note that an URL parameter should be "URL encoded" to avoid the appearance of characters with a special meaning. Use the functions "urlencoded2string" and "string2urlencoded" to decode and encode such parameters, respectively.

urlencoded2string :: String -> String   

Translates urlencoded string into equivalent ASCII string.

string2urlencoded :: String -> String   

Translates arbitrary strings into equivalent urlencoded string.

getCookies :: IO [(String,String)]   

Gets the cookies sent from the browser for the current CGI script. The cookies are represented in the form of name/value pairs since no other components are important here.

coordinates :: (CgiRef -> String) -> Maybe (Int,Int)   

For image buttons: retrieve the coordinates where the user clicked within the image.