Module TypedUI2GUI

Library for creating tcl/tk applications from ui descriptions with combinators you can create your own widgets Ideas and parts of documentation from PAKCS WUI library

Author: Christof Kluss

Version: September 2008

Summary of exported operations:

renderOf :: (a,b,c) -> a   
errorOf :: (a,b,c) -> b   
conditionOf :: (a,b,c) -> c   
withRendering :: UISpec a -> ([Widget WidgetRef (UIEnv -> IO ()) ()] -> Widget WidgetRef (UIEnv -> IO ()) ()) -> UISpec a   
Puts a new rendering function into a UI specification.
withError :: UISpec a -> String -> UISpec a   
Puts a new error message into a UI specification.
withConditionIO :: UISpec a -> (a -> IO Bool) -> UISpec a   
Puts a new condition into a UI specification.
withCondition :: UISpec a -> (a -> Bool) -> UISpec a   
Puts a new condition into a UI specification.
transformWSpec :: (a -> b,b -> a) -> UISpec a -> UISpec b   
Transforms a UI specification from one type to another.
adaptWSpec :: (a -> b) -> UISpec a -> UISpec b   
Adapt a UI specification to a new type.
wInt :: UISpec Int   
A widget for editing integer values.
wConstant :: (a -> Widget WidgetRef (UIEnv -> IO ()) ()) -> UISpec a   
A widget for values that are shown but cannot be modified.
wHidden :: UISpec a   
A hidden widget for a value that is not shown in the UI.
wStringStyles :: [StyleClass] -> UISpec String   
A widget for editing string values
wString :: UISpec String   
A widget for editing string values
wStringSize :: Int -> UISpec String   
A widget for editing string values
wRequiredString :: UISpec String   
A widget for editing string values that are required to be non-empty.
wRequiredStringSize :: Int -> UISpec String   
A widget for editing string values that are required to be non-empty.
errorStyle :: StyleClass   
showError :: ErrorRefs -> Maybe String -> UIEnv -> IO ()   
renderError :: Widget WidgetRef (UIEnv -> IO ()) () -> ErrorRefs -> Widget WidgetRef (UIEnv -> IO ()) ()   
wPair :: (Eq a, Eq b) => UISpec a -> UISpec b -> UISpec (a,b)   
WUI combinator for pairs.
wTriple :: (Eq a, Eq b, Eq c) => UISpec a -> UISpec b -> UISpec c -> UISpec (a,b,c)   
WUI combinator for triples.
w4Tuple :: (Eq a, Eq b, Eq c, Eq d) => UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec (a,b,c,d)   
WUI combinator for tuples of arity 4.
w5Tuple :: (Eq a, Eq b, Eq c, Eq d, Eq e) => UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec e -> UISpec (a,b,c,d,e)   
WUI combinator for tuples of arity 5.
w6Tuple :: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f) => UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec e -> UISpec f -> UISpec (a,b,c,d,e,f)   
WUI combinator for tuples of arity 6.
w7Tuple :: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g) => UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec e -> UISpec f -> UISpec g -> UISpec (a,b,c,d,e,f,g)   
WUI combinator for tuples of arity 7.
w8Tuple :: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h) => UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec e -> UISpec f -> UISpec g -> UISpec h -> UISpec (a,b,c,d,e,f,g,h)   
WUI combinator for tuples of arity 8.
w11Tuple :: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k) => UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec e -> UISpec f -> UISpec g -> UISpec h -> UISpec i -> UISpec j -> UISpec k -> UISpec (a,b,c,d,e,f,g,h,i,j,k)   
WUI combinator for tuples of arity 11.
wCons2 :: (Eq a, Eq b) => (a -> b -> c) -> UISpec a -> UISpec b -> UISpec c   
UI combinator for constructors of arity 2.
wTextArea :: (Int,Int) -> UISpec String   
A widget for editing string values in a text area.
wList :: Eq a => UISpec a -> UISpec [a]   
renderList :: [Widget WidgetRef (UIEnv -> IO ()) ()] -> Widget WidgetRef (UIEnv -> IO ()) ()   
wMultiCheckSelect :: Eq a => (a -> [Widget WidgetRef (UIEnv -> IO ()) ()]) -> [a] -> UISpec [a]   
A widget to select a list of values from a given list of values via check boxes.
newVars :: [a]   
wSelect :: Eq a => (a -> String) -> [a] -> UISpec a   
A widget to select a value from a given list of values.
wSelectInt :: [Int] -> UISpec Int   
A widget to select a value from a given list of integers (provided as the argument).
wSelectBool :: String -> String -> UISpec Bool   
A widget to select a Boolean value via a selection box.
renderTuple :: [Widget WidgetRef (UIEnv -> IO ()) ()] -> Widget WidgetRef (UIEnv -> IO ()) ()   
standard rendering of tuples as a row:
tupleError :: String   
typedui2ui :: UISpec a -> a -> (Widget WidgetRef (UIEnv -> IO ()) (),UIEnv -> IO (Maybe a),a -> UIEnv -> IO (),(a -> a) -> UIEnv -> IO ())   
Generates an UI Widget and a handlers from a UI data specification, an initial value.
typeduistore2ui :: UISpec a -> a -> (a -> UIEnv -> IO ()) -> (Widget WidgetRef (UIEnv -> IO ()) (),UIEnv -> IO ())   
Generates HTML editors and a handler from a WUI data specification, an initial value and an update form.
runUISpec :: UISpec a -> a -> (a -> UIEnv -> IO ()) -> IO ()   
wCons3 :: (Eq a, Eq b, Eq c) => (a -> b -> c -> d) -> UISpec a -> UISpec b -> UISpec c -> UISpec d   
wCons4 :: (Eq a, Eq b, Eq c, Eq d) => (a -> b -> c -> d -> e) -> UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec e   
wCons5 :: (Eq a, Eq b, Eq c, Eq d, Eq e) => (a -> b -> c -> d -> e -> f) -> UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec e -> UISpec f   
wCons6 :: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f) => (a -> b -> c -> d -> e -> f -> g) -> UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec e -> UISpec f -> UISpec g   
wCons7 :: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g) => (a -> b -> c -> d -> e -> f -> g -> h) -> UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec e -> UISpec f -> UISpec g -> UISpec h   
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) -> UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec e -> UISpec f -> UISpec g -> UISpec h -> UISpec i   
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) -> UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec e -> UISpec f -> UISpec g -> UISpec h -> UISpec i -> UISpec j -> UISpec k -> UISpec l   

Exported datatypes:


Rendering

A rendering is a function that combines the visualization of components of a data structure into some HTML expression.

Type synonym: Rendering = [UIWidget] -> UIWidget


UIParams

UIParams specify the parameters of an individual UI component type:

  • the standard rendering
  • an error message shown in case of illegal inputs
  • a condition to specify legal input values

Type synonym: UIParams a = (Rendering,String,a -> IO Bool)


UISpec

The type of UI specifications. The first component are parameters specifying the behavior of this UI type (rendering, error message, and constraints on inputs). The second component is a "show" function returning an UI Widget, a "read" function and a "set" function The "read" function extract the values from the Widget. If the value is not legal, Nothing is returned.

Constructors:


Exported operations:

renderOf :: (a,b,c) -> a   

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

errorOf :: (a,b,c) -> b   

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

conditionOf :: (a,b,c) -> c   

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

withRendering :: UISpec a -> ([Widget WidgetRef (UIEnv -> IO ()) ()] -> Widget WidgetRef (UIEnv -> IO ()) ()) -> UISpec a   

Puts a new rendering function into a UI specification.

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

withError :: UISpec a -> String -> UISpec a   

Puts a new error message into a UI specification.

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

withConditionIO :: UISpec a -> (a -> IO Bool) -> UISpec a   

Puts a new condition into a UI specification.

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

withCondition :: UISpec a -> (a -> Bool) -> UISpec a   

Puts a new condition into a UI specification.

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

transformWSpec :: (a -> b,b -> a) -> UISpec a -> UISpec b   

Transforms a UI specification from one type to another.

adaptWSpec :: (a -> b) -> UISpec a -> UISpec b   

Adapt a UI 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 transformWSpec!

wInt :: UISpec Int   

A widget for editing integer values.

wConstant :: (a -> Widget WidgetRef (UIEnv -> IO ()) ()) -> UISpec a   

A widget for values that are shown but cannot be modified. The first argument is a mapping of the value into a UI Widget to show this value.

wHidden :: UISpec a   

A hidden widget for a value that is not shown in the UI. Usually, this is used in components of larger structures, e.g., internal identifiers, data base keys.

wStringStyles :: [StyleClass] -> UISpec String   

A widget for editing string values

wString :: UISpec String   

A widget for editing string values

wStringSize :: Int -> UISpec String   

A widget for editing string values

wRequiredString :: UISpec String   

A widget for editing string values that are required to be non-empty.

wRequiredStringSize :: Int -> UISpec String   

A widget for editing string values that are required to be non-empty.

errorStyle :: StyleClass   

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

showError :: ErrorRefs -> Maybe String -> UIEnv -> IO ()   

renderError :: Widget WidgetRef (UIEnv -> IO ()) () -> ErrorRefs -> Widget WidgetRef (UIEnv -> IO ()) ()   

wPair :: (Eq a, Eq b) => UISpec a -> UISpec b -> UISpec (a,b)   

WUI combinator for pairs.

wTriple :: (Eq a, Eq b, Eq c) => UISpec a -> UISpec b -> UISpec c -> UISpec (a,b,c)   

WUI combinator for triples.

w4Tuple :: (Eq a, Eq b, Eq c, Eq d) => UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec (a,b,c,d)   

WUI combinator for tuples of arity 4.

w5Tuple :: (Eq a, Eq b, Eq c, Eq d, Eq e) => UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec e -> UISpec (a,b,c,d,e)   

WUI combinator for tuples of arity 5.

w6Tuple :: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f) => UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec e -> UISpec f -> UISpec (a,b,c,d,e,f)   

WUI combinator for tuples of arity 6.

w7Tuple :: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g) => UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec e -> UISpec f -> UISpec g -> UISpec (a,b,c,d,e,f,g)   

WUI combinator for tuples of arity 7.

w8Tuple :: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h) => UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec e -> UISpec f -> UISpec g -> UISpec h -> UISpec (a,b,c,d,e,f,g,h)   

WUI combinator for tuples of arity 8.

w11Tuple :: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k) => UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec e -> UISpec f -> UISpec g -> UISpec h -> UISpec i -> UISpec j -> UISpec k -> UISpec (a,b,c,d,e,f,g,h,i,j,k)   

WUI combinator for tuples of arity 11.

wCons2 :: (Eq a, Eq b) => (a -> b -> c) -> UISpec a -> UISpec b -> UISpec c   

UI combinator for constructors of arity 2. The first argument is the binary constructor. The second and third arguments are the UI specifications for the argument types.

wTextArea :: (Int,Int) -> UISpec String   

A widget for editing string values in a text area. The argument specifies the height and width of the text area.

wList :: Eq a => UISpec a -> UISpec [a]   

renderList :: [Widget WidgetRef (UIEnv -> IO ()) ()] -> Widget WidgetRef (UIEnv -> IO ()) ()   

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

wMultiCheckSelect :: Eq a => (a -> [Widget WidgetRef (UIEnv -> IO ()) ()]) -> [a] -> UISpec [a]   

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.

newVars :: [a]   

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

wSelect :: Eq a => (a -> String) -> [a] -> UISpec a   

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.

wSelectInt :: [Int] -> UISpec Int   

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.

wSelectBool :: String -> String -> UISpec Bool   

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.

Example call:
(wSelectBool true false)
Parameters:
  • true : string for selection of True
  • false : string for selection of False
Returns:
a UI specification for a Boolean selection widget

renderTuple :: [Widget WidgetRef (UIEnv -> IO ()) ()] -> Widget WidgetRef (UIEnv -> IO ()) ()   

standard rendering of tuples as a row:

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

tupleError :: String   

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

typedui2ui :: UISpec a -> a -> (Widget WidgetRef (UIEnv -> IO ()) (),UIEnv -> IO (Maybe a),a -> UIEnv -> IO (),(a -> a) -> UIEnv -> IO ())   

Generates an UI Widget and a handlers from a UI data specification, an initial value.

typeduistore2ui :: UISpec a -> a -> (a -> UIEnv -> IO ()) -> (Widget WidgetRef (UIEnv -> IO ()) (),UIEnv -> IO ())   

Generates HTML editors and a handler from a WUI data specification, an initial value and an update form.

runUISpec :: UISpec a -> a -> (a -> UIEnv -> IO ()) -> IO ()   

wCons3 :: (Eq a, Eq b, Eq c) => (a -> b -> c -> d) -> UISpec a -> UISpec b -> UISpec c -> UISpec d   

wCons4 :: (Eq a, Eq b, Eq c, Eq d) => (a -> b -> c -> d -> e) -> UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec e   

wCons5 :: (Eq a, Eq b, Eq c, Eq d, Eq e) => (a -> b -> c -> d -> e -> f) -> UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec e -> UISpec f   

wCons6 :: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f) => (a -> b -> c -> d -> e -> f -> g) -> UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec e -> UISpec f -> UISpec g   

wCons7 :: (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g) => (a -> b -> c -> d -> e -> f -> g -> h) -> UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec e -> UISpec f -> UISpec g -> UISpec h   

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) -> UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec e -> UISpec f -> UISpec g -> UISpec h -> UISpec i   

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) -> UISpec a -> UISpec b -> UISpec c -> UISpec d -> UISpec e -> UISpec f -> UISpec g -> UISpec h -> UISpec i -> UISpec j -> UISpec k -> UISpec l