Library for constructing static and dynamic HTML pages. This paper contains a description of the basic ideas behind this library.
The installation of a cgi script written with this library can be done by the command
curry makecgi -m initialForm -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 initialForm
            is the Curry expression
(of type IO HtmlForm) computing the HTML form (where curry
            is the shell command calling the Curry system PAKCS or KiCS2).
          
Author: Michael Hanus (with extensions by Bernd Brassel and Marco Comini)
Version: October 2016
| defaultEncoding
                  ::  StringThe default encoding used in generated web pages. | 
| idOfCgiRef
                  ::  CgiRef -> StringInternal identifier of a CgiRef (intended only for internal use in other libraries!). | 
| textOf
                  ::  [HtmlExp] -> StringExtracts the textual contents of a list of HTML expressions. | 
| formEnc
                  ::  String -> FormParamAn encoding scheme for a HTML form. | 
| formCSS
                  ::  String -> FormParamA URL for a CSS file for a HTML form. | 
| formMetaInfo
                  ::  [(String,String)] -> FormParamMeta information for a HTML form. | 
| formBodyAttr
                  ::  (String,String) -> FormParamOptional attribute for the body element of the HTML form. | 
| form
                  ::  String -> [HtmlExp] -> HtmlFormA basic HTML form for active web pages with the default encoding and a default background. | 
| standardForm
                  ::  String -> [HtmlExp] -> HtmlFormA standard HTML form for active web pages where the title is included in the body as the first header. | 
| cookieForm
                  ::  String -> [(String,String)] -> [HtmlExp] -> HtmlFormAn HTML form with simple cookies. | 
| addCookies
                  ::  [(String,String)] -> HtmlForm -> HtmlFormAdd simple cookie to HTML form. | 
| formatCookie
                  ::  (String,String,[CookieParam]) -> String | 
| answerText
                  ::  String -> HtmlFormA textual result instead of an HTML form as a result for active web pages. | 
| answerEncText
                  ::  String -> String -> HtmlFormA textual result instead of an HTML form as a result for active web pages where the encoding is given as the first parameter. | 
| addFormParam
                  ::  HtmlForm -> FormParam -> HtmlFormAdds a parameter to an HTML form. | 
| addFormParams
                  ::  HtmlForm -> [FormParam] -> HtmlForm | 
| redirect
                  ::  Int -> String -> HtmlForm -> HtmlFormAdds redirection to given HTML form. | 
| expires
                  ::  Int -> HtmlForm -> HtmlFormAdds expire time to given HTML form. | 
| addSound
                  ::  String -> Bool -> HtmlForm -> HtmlFormAdds sound to given HTML form. | 
| pageEnc
                  ::  String -> PageParamAn encoding scheme for a HTML page. | 
| pageCSS
                  ::  String -> PageParamA URL for a CSS file for a HTML page. | 
| pageMetaInfo
                  ::  [(String,String)] -> PageParamMeta information for a HTML page. | 
| pageLinkInfo
                  ::  [(String,String)] -> PageParamLink information for a HTML page. | 
| pageBodyAttr
                  ::  (String,String) -> PageParamOptional attribute for the body element of the web page. | 
| page
                  ::  String -> [HtmlExp] -> HtmlPageA basic HTML web page with the default encoding. | 
| standardPage
                  ::  String -> [HtmlExp] -> HtmlPageA standard HTML web page where the title is included in the body as the first header. | 
| addPageParam
                  ::  HtmlPage -> PageParam -> HtmlPageAdds a parameter to an HTML page. | 
| htxt
                  ::  String -> HtmlExpBasic text as HTML expression. | 
| htxts
                  ::  [String] -> [HtmlExp]A list of strings represented as a list of HTML expressions. | 
| hempty
                  ::  HtmlExpAn empty HTML expression. | 
| nbsp
                  ::  HtmlExpNon breaking Space | 
| h1
                  ::  [HtmlExp] -> HtmlExpHeader 1 | 
| h2
                  ::  [HtmlExp] -> HtmlExpHeader 2 | 
| h3
                  ::  [HtmlExp] -> HtmlExpHeader 3 | 
| h4
                  ::  [HtmlExp] -> HtmlExpHeader 4 | 
| h5
                  ::  [HtmlExp] -> HtmlExpHeader 5 | 
| par
                  ::  [HtmlExp] -> HtmlExpParagraph | 
| section
                  ::  [HtmlExp] -> HtmlExpSection | 
| header
                  ::  [HtmlExp] -> HtmlExpHeader | 
| 
                  ::  [HtmlExp] -> HtmlExpFooter | 
| emphasize
                  ::  [HtmlExp] -> HtmlExpEmphasize | 
| strong
                  ::  [HtmlExp] -> HtmlExpStrong (more emphasized) text. | 
| bold
                  ::  [HtmlExp] -> HtmlExpBoldface | 
| italic
                  ::  [HtmlExp] -> HtmlExpItalic | 
| 
                  ::  [HtmlExp] -> HtmlExpNavigation | 
| code
                  ::  [HtmlExp] -> HtmlExpProgram code | 
| center
                  ::  [HtmlExp] -> HtmlExpCentered text | 
| blink
                  ::  [HtmlExp] -> HtmlExpBlinking text | 
| teletype
                  ::  [HtmlExp] -> HtmlExpTeletype font | 
| pre
                  ::  [HtmlExp] -> HtmlExpUnformatted input, i.e., keep spaces and line breaks and don't quote special characters. | 
| verbatim
                  ::  String -> HtmlExpVerbatim (unformatted), special characters (<,>,&,") are quoted. | 
| address
                  ::  [HtmlExp] -> HtmlExpAddress | 
| href
                  ::  String -> [HtmlExp] -> HtmlExpHypertext reference | 
| anchor
                  ::  String -> [HtmlExp] -> HtmlExpAn anchored text with a hypertext reference inside a document. | 
| ulist
                  ::  [[HtmlExp]] -> HtmlExpUnordered list | 
| olist
                  ::  [[HtmlExp]] -> HtmlExpOrdered list | 
| litem
                  ::  [HtmlExp] -> HtmlExpA single list item (usually not explicitly used) | 
| dlist
                  ::  [([HtmlExp],[HtmlExp])] -> HtmlExpDescription list | 
| table
                  ::  [[[HtmlExp]]] -> HtmlExpTable with a matrix of items where each item is a list of HTML expressions. | 
| headedTable
                  ::  [[[HtmlExp]]] -> HtmlExpSimilar to tablebut introduces header tags for the first row. | 
| addHeadings
                  ::  HtmlExp -> [[HtmlExp]] -> HtmlExpAdd a row of items (where each item is a list of HTML expressions) as headings to a table. | 
| hrule
                  ::  HtmlExpHorizontal rule | 
| breakline
                  ::  HtmlExpBreak a line | 
| image
                  ::  String -> String -> HtmlExpImage | 
| styleSheet
                  ::  String -> HtmlExpDefines a style sheet to be used in this HTML document. | 
| style
                  ::  String -> [HtmlExp] -> HtmlExpProvides a style for HTML elements. | 
| textstyle
                  ::  String -> String -> HtmlExpProvides a style for a basic text. | 
| blockstyle
                  ::  String -> [HtmlExp] -> HtmlExpProvides a style for a block of HTML elements. | 
| inline
                  ::  [HtmlExp] -> HtmlExpJoins a list of HTML elements into a single HTML element. | 
| block
                  ::  [HtmlExp] -> HtmlExpJoins a list of HTML elements into a block. | 
| button
                  ::  String -> ((CgiRef -> String) -> IO HtmlForm) -> HtmlExpSubmit button with a label string and an event handler | 
| resetbutton
                  ::  String -> HtmlExpReset button with a label string | 
| imageButton
                  ::  String -> ((CgiRef -> String) -> IO HtmlForm) -> HtmlExpSubmit button in form of an imag. | 
| textfield
                  ::  CgiRef -> String -> HtmlExpInput text field with a reference and an initial contents | 
| password
                  ::  CgiRef -> HtmlExpInput text field (where the entered text is obscured) with a reference | 
| textarea
                  ::  CgiRef -> (Int,Int) -> String -> HtmlExpInput text area with a reference, height/width, and initial contents | 
| checkbox
                  ::  CgiRef -> String -> HtmlExpA checkbox with a reference and a value. | 
| checkedbox
                  ::  CgiRef -> String -> HtmlExpA checkbox that is initially checked with a reference and a value. | 
| radio_main
                  ::  CgiRef -> String -> HtmlExpA main button of a radio (initially "on") with a reference and a value. | 
| radio_main_off
                  ::  CgiRef -> String -> HtmlExpA main button of a radio (initially "off") with a reference and a value. | 
| radio_other
                  ::  CgiRef -> String -> HtmlExpA 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)] -> HtmlExpA selection button with a reference and a list of name/value pairs. | 
| selectionInitial
                  ::  CgiRef -> [(String,String)] -> Int -> HtmlExpA selection button with a reference, a list of name/value pairs, and a preselected item in this list. | 
| multipleSelection
                  ::  CgiRef -> [(String,String,Bool)] -> HtmlExpA selection button with a reference and a list of name/value/flag pairs. | 
| 
                  ::  String -> String -> HtmlExpA hidden field to pass a value referenced by a fixed name. | 
| htmlQuote
                  ::  String -> StringQuotes special characters ( <,>,&,", umlauts) in a string
as HTML special characters. | 
| htmlIsoUmlauts
                  ::  String -> StringTranslates umlauts in iso-8859-1 encoding into HTML special characters. | 
| addAttr
                  ::  HtmlExp -> (String,String) -> HtmlExpAdds an attribute (name/value pair) to an HTML element. | 
| addAttrs
                  ::  HtmlExp -> [(String,String)] -> HtmlExpAdds a list of attributes (name/value pair) to an HTML element. | 
| addClass
                  ::  HtmlExp -> String -> HtmlExpAdds a class attribute to an HTML element. | 
| showHtmlExps
                  ::  [HtmlExp] -> StringTransforms a list of HTML expressions into string representation. | 
| showHtmlExp
                  ::  HtmlExp -> StringTransforms a single HTML expression into string representation. | 
| showHtmlPage
                  ::  HtmlPage -> StringTransforms HTML page into string representation. | 
| htmlPrelude
                  ::  StringStandard header for generated HTML pages. | 
| htmlTagAttrs
                  ::  [(String,String)]Standard attributes for element "html". | 
| getUrlParameter
                  ::  IO StringGets the parameter attached to the URL of the script. | 
| urlencoded2string
                  ::  String -> StringTranslates urlencoded string into equivalent ASCII string. | 
| string2urlencoded
                  ::  String -> StringTranslates 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. | 
The (abstract) data type for representing references to input elements in HTML forms.
Constructors:
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
            
The type of event handlers in HTML forms.
              Type synonym: HtmlHandler = CgiEnv -> IO HtmlForm
            
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 ->  HtmlHandler -> HtmlExp
                : an input element (first arg) with an associated
                         event handler (tpyically, a submit button)
              The data type for representing HTML forms (active web pages) and return values of HTML forms.
Constructors:
HtmlForm
                    ::  String ->  [FormParam] ->  [HtmlExp] -> HtmlForm
                : an HTML form with title t, optional parameters
        (e.g., cookies) ps, and contents hs
              HtmlAnswer
                    ::  String ->  String -> HtmlForm
                : an answer in an arbitrary format where t
        is the content type (e.g., "text/plain") and c is the contents
              The possible parameters of an HTML form. The parameters of a cookie (FormCookie) 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:
FormCookie
                    ::  String ->  String ->  [CookieParam] -> FormParam
                : a cookie to be sent to the
                                     client's browser
              FormCSS
                    ::  String -> FormParam
                : a URL for a CSS file for this form
              FormJScript
                    ::  String -> FormParam
                : a URL for a Javascript file for this form
              FormOnSubmit
                    ::  String -> FormParam
                : a JavaScript statement to be executed when the form
                       is submitted (i.e., <form ... onsubmit="s">)
              FormTarget
                    ::  String -> FormParam
                : a name of a target frame where the output of the
                     script should be represented (should only be used
                     for scripts running in a frame)
              FormEnc
                    ::  String -> FormParam
                : the encoding scheme of this form
              FormMeta
                    ::  [(String,String)] -> FormParam
                : meta information (in form of attributes) for this form
              HeadInclude
                    ::  HtmlExp -> FormParam
                : HTML expression to be included in form header
              MultipleHandlers
                    :: FormParam
                : indicates that the event handlers of the form
  can be multiply used (i.e., are not deleted if the form is submitted
  so that they are still available when going back in the browser;
  but then there is a higher risk that the web server process
  might overflow with unused events); the default is a single use
  of event handlers, i.e., one cannot use the back button in the
  browser and submit the same form again (which is usually
  a reasonable behavior to avoid double submissions of data).
              BodyAttr
                    ::  (String,String) -> FormParam
                : optional attribute for the body element (more than
                     one occurrence is allowed)
              The possible parameters of a cookie.
Constructors:
CookieExpire
                    ::  ClockTime -> CookieParam
              CookieDomain
                    ::  String -> CookieParam
              CookiePath
                    ::  String -> CookieParam
              CookieSecure
                    :: CookieParam
              The data type for representing HTML pages. The constructor arguments are the title, the parameters, and the contents (body) of the web page.
Constructors:
The possible parameters of an HTML page.
Constructors:
PageEnc
                    ::  String -> PageParam
                : the encoding scheme of this page
              PageCSS
                    ::  String -> PageParam
                : a URL for a CSS file for 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
              PageBodyAttr
                    ::  (String,String) -> PageParam
                : optional attribute for the body element of the
                          page (more than one occurrence is allowed)
              | 
                       The default encoding used in generated web pages. 
 | 
| 
                       Internal identifier of a CgiRef (intended only for internal use in other libraries!). 
 | 
| Extracts the textual contents of a list of HTML expressions. 
                      For instance,
 | 
| 
                       An encoding scheme for a HTML form. 
 | 
| 
                       A URL for a CSS file for a HTML form. 
 | 
| 
                       
                      Meta information for a HTML form. The argument is a list of
attributes included in the  
 | 
| 
                       Optional attribute for the body element of the HTML form. More than one occurrence is allowed, i.e., all such attributes are collected. 
 | 
| 
                       A basic HTML form for active web pages with the default encoding and a default background. 
 
 
 
 | 
| 
                       A standard HTML form for active web pages where the title is included in the body as the first header. 
 
 
 | 
| 
                       An HTML form with simple cookies. The cookies are sent to the client's browser together with this form. 
 
 
 | 
| 
                       Add simple cookie to HTML form. The cookies are sent to the client's browser together with this form. 
 
 
 | 
| 
                       | 
| 
                       A textual result instead of an HTML form as a result for active web pages. 
 
 
 
 | 
| 
                       A textual result instead of an HTML form as a result for active web pages where the encoding is given as the first parameter. 
 
 
 
 | 
| 
                       Adds a parameter to an HTML form. 
 
 
 
 | 
| 
                       
 | 
| 
                       Adds redirection to given HTML form. 
 
 | 
| 
                       Adds expire time to given HTML form. 
 
 | 
| 
                       Adds sound to given HTML form. The functions adds two different declarations for sound, one invented by Microsoft for the internet explorer, one introduced for netscape. As neither is an official part of HTML, addsound might not work on all systems and browsers. The greatest chance is by using sound files in MID-format. 
 
 | 
| 
                       An encoding scheme for a HTML page. 
 | 
| 
                       A URL for a CSS file for a HTML page. 
 | 
| 
                       
                      Meta information for a HTML page. The argument is a list of
attributes included in the  
 | 
| 
                       
                      Link information for a HTML page. The argument is a list of
attributes included in the  
 | 
| 
                       Optional attribute for the body element of the web page. More than one occurrence is allowed, i.e., all such attributes are collected. 
 | 
| 
                       A basic HTML web page with the default encoding. 
 
 
 
 | 
| 
                       A standard HTML web page where the title is included in the body as the first header. 
 
 
 | 
| 
                       Adds a parameter to an HTML page. 
 
 
 
 | 
| 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. | 
| 
                       A list of strings represented as a list of HTML expressions. The strings may contain special HTML chars that will be quoted. | 
| An empty HTML expression. 
 | 
| Non breaking Space 
 | 
| Header 1 
 | 
| Header 2 
 | 
| Header 3 
 | 
| Header 4 
 | 
| Header 5 
 | 
| Paragraph 
 | 
| 
                       Section 
 | 
| 
                       Header 
 | 
| 
                       Emphasize 
 | 
| 
                       Strong (more emphasized) text. 
 | 
| Boldface 
 | 
| 
                       Italic 
 | 
| Program code 
 | 
| 
                       Centered text 
 | 
| Blinking text 
 | 
| 
                       Teletype font 
 | 
| Unformatted input, i.e., keep spaces and line breaks and don't quote special characters. 
 | 
| 
                       Address 
 | 
| 
                       Hypertext reference 
 | 
| 
                       An anchored text with a hypertext reference inside a document. 
 | 
| 
                       Unordered list 
 
 | 
| 
                       Ordered list 
 
 | 
| A single list item (usually not explicitly used) 
 | 
| 
                       Description list 
 
 | 
| 
                       Table with a matrix of items where each item is a list of HTML expressions. | 
| 
                       
                      Similar to  | 
| 
                       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. | 
| Horizontal rule 
 | 
| Break a line 
 | 
| 
                       Image 
 
 | 
| 
                       Defines a style sheet to be used in this HTML document. 
 
 
 | 
| 
                       
                      Provides a style for HTML elements.
The style argument is the name of a style class defined in a
style definition (see  
 
 
 | 
| 
                       Provides a style for a basic text. The style argument is the name of a style class defined in an external style sheet. 
 
 | 
| 
                       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. 
 
 
 | 
| 
                       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. 
 
 
 | 
| Joins a list of HTML elements into a block. A line break is placed before and after these elements. 
 
 
 | 
| 
                       Submit button with a label string and an event handler | 
| 
                       Reset button with a label string | 
| 
                       Submit button in form of an imag. 
 
 
 | 
| Input text field (where the entered text is obscured) with a reference | 
| 
                       Input text area with a reference, height/width, and initial contents | 
| 
                       A checkbox with a reference and a value. The value is returned if checkbox is on, otherwise "" is returned. | 
| 
                       A checkbox that is initially checked with a reference and a value. The value is returned if checkbox is on, otherwise "" is returned. | 
| 
                       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. | 
| 
                       A main button of a radio (initially "off") with a reference and a value. The value is returned of this button is on. | 
| 
                       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. | 
| 
                       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. | 
| 
                       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. 
 
 
 | 
| 
                       
                      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 ( | 
| 
                       
                      Quotes special characters ( | 
| 
                       Translates umlauts in iso-8859-1 encoding into HTML special characters. | 
| 
                       Adds an attribute (name/value pair) to an HTML element. 
 | 
| 
                       Adds a list of attributes (name/value pair) to an HTML element. 
 | 
| 
                       Adds a class attribute to an HTML element. 
 | 
| 
                       Transforms a list of HTML expressions into string representation. | 
| 
                       Transforms a single HTML expression into string representation. | 
| 
                       Transforms HTML page into string representation. 
 
 
 | 
| 
                       Standard header for generated HTML pages. 
 | 
| 
                       Standard attributes for element "html". 
 | 
| 
                       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. | 
| 
                       Translates urlencoded string into equivalent ASCII string. | 
| 
                       Translates arbitrary strings into equivalent urlencoded 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. | 
| 
                       For image buttons: retrieve the coordinates where the user clicked within the image. |