Generates an HTML form from a WUI data specification, an initial value and an update form. |
A library to support the type-oriented construction of Web User Interfaces (WUIs).
The ideas behind the application and implementation of WUIs are described in a paper that is available via this web page.
Author: Michael Hanus
Version: January 2018
wuiHandler2button
:: String -> WuiHandler -> HtmlExp
Transform a WUI handler into a submit button with a given label string. |
withRendering
:: WuiSpec a -> ([HtmlExp] -> HtmlExp) -> WuiSpec a
Puts a new rendering function into a WUI specification. |
withError
:: WuiSpec a -> String -> WuiSpec a
Puts a new error message into a WUI specification. |
withCondition
:: WuiSpec a -> (a -> Bool) -> WuiSpec a
Puts a new condition into a WUI specification. |
transformWSpec
:: (a -> b,b -> a) -> WuiSpec a -> WuiSpec b
Transforms a WUI specification from one type to another. |
adaptWSpec
:: (a -> b) -> WuiSpec a -> WuiSpec b
Adapt a WUI specification to a new type. |
wHidden
:: WuiSpec a
A hidden widget for a value that is not shown in the WUI. |
wConstant
:: (a -> HtmlExp) -> WuiSpec a
A widget for values that are shown but cannot be modified. |
wInt
:: WuiSpec Int
A widget for editing integer values. |
wString
:: WuiSpec String
A widget for editing string values. |
wStringSize
:: Int -> WuiSpec String
A widget for editing string values with a size attribute. |
wRequiredString
:: WuiSpec String
A widget for editing string values that are required to be non-empty. |
wRequiredStringSize
:: Int -> WuiSpec String
A widget with a size attribute for editing string values that are required to be non-empty. |
wTextArea
:: (Int,Int) -> WuiSpec String
A widget for editing string values in a text area. |
wSelect
:: Eq a => (a -> String) -> [a] -> WuiSpec a
A widget to select a value from a given list of values. |
wSelectInt
:: [Int] -> WuiSpec Int
A widget to select a value from a given list of integers (provided as the argument). |
wSelectBool
:: String -> String -> WuiSpec Bool
A widget to select a Boolean value via a selection box. |
wCheckBool
:: [HtmlExp] -> WuiSpec Bool
A widget to select a Boolean value via a check box. |
wMultiCheckSelect
:: Eq a => (a -> [HtmlExp]) -> [a] -> WuiSpec [a]
A widget to select a list of values from a given list of values via check boxes. |
wRadioSelect
:: Eq a => (a -> [HtmlExp]) -> [a] -> WuiSpec a
A widget to select a value from a given list of values via a radio button. |
wRadioBool
:: [HtmlExp] -> [HtmlExp] -> WuiSpec Bool
A widget to select a Boolean value via a radio button. |
wPair
:: (Eq a, Eq b) => WuiSpec a -> WuiSpec b -> WuiSpec (a,b)
WUI combinator for pairs. |
wCons2
:: (Eq a, Eq b) => (a -> b -> c) -> WuiSpec a -> WuiSpec b -> WuiSpec c
WUI combinator for constructors of arity 2. |
wTriple
:: (Eq a, Eq b, Eq c) => WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec (a,b,c)
WUI combinator for triples. |
wCons3
:: (Eq a, Eq b, Eq c) => (a -> b -> c -> d) -> WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d
WUI combinator for constructors of arity 3. |
w4Tuple
:: (Eq a, Eq b, Eq c, Eq d) => WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d -> WuiSpec (a,b,c,d)
WUI combinator for tuples of arity 4. |
wCons4
:: (Eq a, Eq b, Eq c, Eq d) => (a -> b -> c -> d -> e) -> WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d -> WuiSpec e
WUI combinator for constructors of arity 4. |
w5Tuple
:: (Eq a, Eq b, Eq c, Eq d, Eq e) => WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d -> WuiSpec e -> WuiSpec (a,b,c,d,e)
WUI combinator for tuples of arity 5. |
wCons5
:: (Eq a, Eq b, Eq c, Eq d, Eq e) => (a -> b -> c -> d -> e -> f) -> WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d -> WuiSpec e -> WuiSpec f
WUI combinator for constructors of arity 5. |
w6Tuple
:: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f) => WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d -> WuiSpec e -> WuiSpec f -> WuiSpec (a,b,c,d,e,f)
WUI combinator for tuples of arity 6. |
wCons6
:: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f) => (a -> b -> c -> d -> e -> f -> g) -> WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d -> WuiSpec e -> WuiSpec f -> WuiSpec g
WUI combinator for constructors of arity 6. |
w7Tuple
:: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g) => WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d -> WuiSpec e -> WuiSpec f -> WuiSpec g -> WuiSpec (a,b,c,d,e,f,g)
WUI combinator for tuples of arity 7. |
wCons7
:: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g) => (a -> b -> c -> d -> e -> f -> g -> h) -> WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d -> WuiSpec e -> WuiSpec f -> WuiSpec g -> WuiSpec h
WUI combinator for constructors of arity 7. |
w8Tuple
:: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h) => WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d -> WuiSpec e -> WuiSpec f -> WuiSpec g -> WuiSpec h -> WuiSpec (a,b,c,d,e,f,g,h)
WUI combinator for tuples of arity 8. |
wCons8
:: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h) => (a -> b -> c -> d -> e -> f -> g -> h -> i) -> WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d -> WuiSpec e -> WuiSpec f -> WuiSpec g -> WuiSpec h -> WuiSpec i
WUI combinator for constructors of arity 8. |
w9Tuple
:: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i) => WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d -> WuiSpec e -> WuiSpec f -> WuiSpec g -> WuiSpec h -> WuiSpec i -> WuiSpec (a,b,c,d,e,f,g,h,i)
WUI combinator for tuples of arity 9. |
wCons9
:: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j) -> WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d -> WuiSpec e -> WuiSpec f -> WuiSpec g -> WuiSpec h -> WuiSpec i -> WuiSpec j
WUI combinator for constructors of arity 9. |
w10Tuple
:: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j) => WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d -> WuiSpec e -> WuiSpec f -> WuiSpec g -> WuiSpec h -> WuiSpec i -> WuiSpec j -> WuiSpec (a,b,c,d,e,f,g,h,i,j)
WUI combinator for tuples of arity 10. |
wCons10
:: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k) -> WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d -> WuiSpec e -> WuiSpec f -> WuiSpec g -> WuiSpec h -> WuiSpec i -> WuiSpec j -> WuiSpec k
WUI combinator for constructors of arity 10. |
w11Tuple
:: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k) => WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d -> WuiSpec e -> WuiSpec f -> WuiSpec g -> WuiSpec h -> WuiSpec i -> WuiSpec j -> WuiSpec k -> WuiSpec (a,b,c,d,e,f,g,h,i,j,k)
WUI combinator for tuples of arity 11. |
wCons11
:: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l) -> WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d -> WuiSpec e -> WuiSpec f -> WuiSpec g -> WuiSpec h -> WuiSpec i -> WuiSpec j -> WuiSpec k -> WuiSpec l
WUI combinator for constructors of arity 11. |
w12Tuple
:: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l) => WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d -> WuiSpec e -> WuiSpec f -> WuiSpec g -> WuiSpec h -> WuiSpec i -> WuiSpec j -> WuiSpec k -> WuiSpec l -> WuiSpec (a,b,c,d,e,f,g,h,i,j,k,l)
WUI combinator for tuples of arity 12. |
wCons12
:: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m) -> WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d -> WuiSpec e -> WuiSpec f -> WuiSpec g -> WuiSpec h -> WuiSpec i -> WuiSpec j -> WuiSpec k -> WuiSpec l -> WuiSpec m
WUI combinator for constructors of arity 12. |
w13Tuple
:: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m) => WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d -> WuiSpec e -> WuiSpec f -> WuiSpec g -> WuiSpec h -> WuiSpec i -> WuiSpec j -> WuiSpec k -> WuiSpec l -> WuiSpec m -> WuiSpec (a,b,c,d,e,f,g,h,i,j,k,l,m)
WUI combinator for tuples of arity 13. |
wCons13
:: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n) -> WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d -> WuiSpec e -> WuiSpec f -> WuiSpec g -> WuiSpec h -> WuiSpec i -> WuiSpec j -> WuiSpec k -> WuiSpec l -> WuiSpec m -> WuiSpec n
WUI combinator for constructors of arity 13. |
w14Tuple
:: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n) => WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d -> WuiSpec e -> WuiSpec f -> WuiSpec g -> WuiSpec h -> WuiSpec i -> WuiSpec j -> WuiSpec k -> WuiSpec l -> WuiSpec m -> WuiSpec n -> WuiSpec (a,b,c,d,e,f,g,h,i,j,k,l,m,n)
WUI combinator for tuples of arity 14. |
wCons14
:: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l, Eq m, Eq n) => (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k -> l -> m -> n -> o) -> WuiSpec a -> WuiSpec b -> WuiSpec c -> WuiSpec d -> WuiSpec e -> WuiSpec f -> WuiSpec g -> WuiSpec h -> WuiSpec i -> WuiSpec j -> WuiSpec k -> WuiSpec l -> WuiSpec m -> WuiSpec n -> WuiSpec o
WUI combinator for constructors of arity 14. |
wJoinTuple
:: (Eq a, Eq b) => WuiSpec a -> WuiSpec b -> WuiSpec (a,b)
WUI combinator to combine two tuples into a joint tuple. |
wList
:: Eq a => WuiSpec a -> WuiSpec [a]
WUI combinator for list structures where the list elements are vertically aligned in a table. |
wListWithHeadings
:: Eq a => [String] -> WuiSpec a -> WuiSpec [a]
Add headings to a standard WUI for list structures: |
wHList
:: Eq a => WuiSpec a -> WuiSpec [a]
WUI combinator for list structures where the list elements are horizontally aligned in a table. |
wMatrix
:: Eq a => WuiSpec a -> WuiSpec [[a]]
WUI for matrices, i.e., list of list of elements visualized as a matrix. |
wMaybe
:: Eq a => WuiSpec Bool -> WuiSpec a -> a -> WuiSpec (Maybe a)
WUI for Maybe values. |
wCheckMaybe
:: Eq a => WuiSpec a -> [HtmlExp] -> a -> WuiSpec (Maybe a)
A WUI for Maybe values where a check box is used to select Just. |
wRadioMaybe
:: Eq a => WuiSpec a -> [HtmlExp] -> [HtmlExp] -> a -> WuiSpec (Maybe a)
A WUI for Maybe values where radio buttons are used to switch between Nothing and Just. |
wEither
:: (Eq a, Eq b) => WuiSpec a -> WuiSpec b -> WuiSpec (Either a b)
WUI for union types. |
wTree
:: Eq a => WuiSpec a -> WuiSpec (WTree a)
WUI for tree types. |
renderTuple
:: [HtmlExp] -> HtmlExp
Standard rendering of tuples as a table with a single row. |
renderTaggedTuple
:: [String] -> [HtmlExp] -> HtmlExp
Standard rendering of tuples with a tag for each element. |
renderList
:: [HtmlExp] -> HtmlExp
Standard rendering of lists as a table with a row for each item: Thus, the elements are vertically aligned. |
mainWUI
:: WuiSpec a -> a -> (a -> IO HtmlForm) -> IO HtmlForm
Generates an HTML form from a WUI data specification, an initial value and an update form. |
wui2html
:: WuiSpec a -> a -> (a -> IO HtmlForm) -> (HtmlExp,WuiHandler)
Generates HTML editors and a handler from a WUI data specification, an initial value and an update form. |
wuiInForm
:: WuiSpec a -> a -> (a -> IO HtmlForm) -> (HtmlExp -> WuiHandler -> IO HtmlForm) -> IO HtmlForm
Puts a WUI into a HTML form containing "holes" for the WUI and the handler. |
wuiWithErrorForm
:: WuiSpec a -> a -> (a -> IO HtmlForm) -> (HtmlExp -> WuiHandler -> IO HtmlForm) -> (HtmlExp,WuiHandler)
Generates HTML editors and a handler from a WUI data specification, an initial value and an update form. |
A rendering is a function that combines the visualization of components of a data structure into some HTML expression.
Type synonym: Rendering = [HtmlExp] -> HtmlExp
A handler for a WUI is an event handler for HTML forms possibly with some specific code attached (for future extensions).
Constructors:
The type of WUI specifications. The first component are parameters specifying the behavior of this WUI type (rendering, error message, and constraints on inputs). The second component is a "show" function returning an HTML expression for the edit fields and a WUI state containing the CgiRefs to extract the values from the edit fields. The third component is "read" function to extract the values from the edit fields for a given cgi environment (returned as (Just v)). If the value is not legal, Nothing is returned. The second component of the result contains an HTML edit expression together with a WUI state to edit the value again.
Constructors:
A simple tree structure to demonstrate the construction of WUIs for tree types.
Constructors:
WLeaf
:: a -> WTree a
WNode
:: [WTree a] -> WTree a
Transform a WUI handler into a submit button with a given label string. |
Puts a new rendering function into a WUI specification.
|
Puts a new error message into a WUI specification.
|
Puts a new condition into a WUI specification.
|
Transforms a WUI specification from one type to another. |
Adapt a WUI specification to a new type. For this purpose,
the first argument must be a transformation mapping values
from the old type to the new type. This function must be bijective
and operationally invertible (i.e., the inverse must be computable
by narrowing). Otherwise, use |
A hidden widget for a value that is not shown in the WUI. Usually, this is used in components of larger structures, e.g., internal identifiers, data base keys. |
A widget for values that are shown but cannot be modified. The first argument is a mapping of the value into a HTML expression to show this value. |
A widget for editing string values with a size attribute. |
A widget for editing string values that are required to be non-empty. |
A widget with a size attribute for editing string values that are required to be non-empty. |
A widget for editing string values in a text area. The argument specifies the height and width of the text area. |
A widget to select a value from a given list of values. The current value should be contained in the value list and is preselected. The first argument is a mapping from values into strings to be shown in the selection widget. |
A widget to select a value from a given list of integers (provided as the argument). The current value should be contained in the value list and is preselected. |
A widget to select a Boolean value via a selection box. The arguments are the strings that are shown for the values True and False in the selection box, respectively.
|
A widget to select a Boolean value via a check box. The first argument are HTML expressions that are shown after the check box. The result is True if the box is checked. |
A widget to select a list of values from a given list of values via check boxes. The current values should be contained in the value list and are preselected. The first argument is a mapping from values into HTML expressions that are shown for each item after the check box. |
A widget to select a value from a given list of values via a radio button. The current value should be contained in the value list and is preselected. The first argument is a mapping from values into HTML expressions that are shown for each item after the radio button. |
A widget to select a Boolean value via a radio button. The arguments are the lists of HTML expressions that are shown after the True and False radio buttons, respectively.
|
WUI combinator for constructors of arity 2. The first argument is the binary constructor. The second and third arguments are the WUI specifications for the argument types. |
WUI combinator for triples. |
WUI combinator for constructors of arity 3. The first argument is the ternary constructor. The further arguments are the WUI specifications for the argument types. |
WUI combinator for tuples of arity 4. |
WUI combinator for constructors of arity 4. The first argument is the ternary constructor. The further arguments are the WUI specifications for the argument types. |
WUI combinator for tuples of arity 5. |
WUI combinator for constructors of arity 5. The first argument is the ternary constructor. The further arguments are the WUI specifications for the argument types. |
WUI combinator for tuples of arity 6. |
WUI combinator for constructors of arity 6. The first argument is the ternary constructor. The further arguments are the WUI specifications for the argument types. |
WUI combinator for tuples of arity 7. |
WUI combinator for constructors of arity 7. The first argument is the ternary constructor. The further arguments are the WUI specifications for the argument types. |
WUI combinator for tuples of arity 8. |
WUI combinator for constructors of arity 8. The first argument is the ternary constructor. The further arguments are the WUI specifications for the argument types. |
WUI combinator for tuples of arity 9. |
WUI combinator for constructors of arity 9. The first argument is the ternary constructor. The further arguments are the WUI specifications for the argument types. |
WUI combinator for tuples of arity 10. |
WUI combinator for constructors of arity 10. The first argument is the ternary constructor. The further arguments are the WUI specifications for the argument types. |
WUI combinator for tuples of arity 11. |
WUI combinator for constructors of arity 11. The first argument is the ternary constructor. The further arguments are the WUI specifications for the argument types. |
WUI combinator for tuples of arity 12. |
WUI combinator for constructors of arity 12. The first argument is the ternary constructor. The further arguments are the WUI specifications for the argument types. |
WUI combinator for tuples of arity 13. |
WUI combinator for constructors of arity 13. The first argument is the ternary constructor. The further arguments are the WUI specifications for the argument types. |
WUI combinator for tuples of arity 14. |
WUI combinator for constructors of arity 14. The first argument is the ternary constructor. The further arguments are the WUI specifications for the argument types. |
WUI combinator to combine two tuples into a joint tuple.
It is similar to wPair but renders both components as a single
tuple provided that the components are already rendered as tuples,
i.e., by the rendering function |
WUI combinator for list structures where the list elements are vertically aligned in a table. |
Add headings to a standard WUI for list structures: |
WUI combinator for list structures where the list elements are horizontally aligned in a table. |
WUI for matrices, i.e., list of list of elements visualized as a matrix. |
WUI for Maybe values. It is constructed from a WUI for Booleans and a WUI for the potential values. Nothing corresponds to a selection of False in the Boolean WUI. The value WUI is shown after the Boolean WUI.
|
A WUI for Maybe values where a check box is used to select Just. The value WUI is shown after the check box.
|
A WUI for Maybe values where radio buttons are used to switch between Nothing and Just. The value WUI is shown after the radio button WUI.
|
WUI for union types. Here we provide only the implementation for Either types since other types with more alternatives can be easily reduced to this case. |
WUI for tree types. The rendering specifies the rendering of inner nodes. Leaves are shown with their default rendering. |
Standard rendering of tuples as a table with a single row. Thus, the elements are horizontally aligned. |
Standard rendering of tuples with a tag for each element. Thus, each is preceded by a tag, that is set in bold, and all elements are vertically aligned. |
Standard rendering of lists as a table with a row for each item: Thus, the elements are vertically aligned. |
Generates an HTML form from a WUI data specification, an initial value and an update form. |
Generates HTML editors and a handler from a WUI data specification, an initial value and an update form. |
Puts a WUI into a HTML form containing "holes" for the WUI and the handler. |
Generates HTML editors and a handler from a WUI data specification, an initial value and an update form. In addition to wui2html, we can provide a skeleton form used to show illegal inputs. |