Commit ae109810 authored by Peter Achten's avatar Peter Achten
Browse files

refactoring modules internally

parent a03eb145
......@@ -35,4 +35,4 @@ loops :: !(GecCircuit (a, b) (c, b)) -> GecCircuit a c | iData b
// to lift library functions to the circuit domain
lift :: !(InIDataId a) (!(InIDataId a) !*HSt -> (!Form b,!*HSt)) -> GecCircuit a b
lift :: !(InIDataId a) ((InIDataId a) *HSt -> (Form b,*HSt)) -> GecCircuit a b
......@@ -89,7 +89,7 @@ where
# (HGC gecbc) = bgecbc {changed = bch, value = b, form = map snd bbody}
= gecbc ((b,bbody ++ abody),ach||bch,hst)
lift :: !(InIDataId a) (!(InIDataId a) !*HSt -> (!Form b,!*HSt)) -> GecCircuit a b
lift :: !(InIDataId a) ((InIDataId a) *HSt -> (Form b,*HSt)) -> GecCircuit a b
lift (Set,formid) fun = HGC fun`
where
fun` ((a,body),ch,hst)
......
This diff is collapsed.
This diff is collapsed.
......@@ -119,7 +119,7 @@ reuseFormId :: !(FormId a) !d -> FormId d // reuse id for new type (only to b
initID :: !(FormId d) -> InIDataId d // (Init,FormId a)
setID :: !(FormId d) !d -> InIDataId d // (Set,FormId a)
onMode :: !Mode a a a -> a // choose arg depending on Edit, Display, NoForm
onMode :: !Mode a a a -> a // chose arg depending on Edit, Display, NoForm
// manipulating initial values
......
......@@ -7,24 +7,24 @@ import StdEnv, htmlHandler, htmlButtons
// **** easy creation of a simple html page ****
mkHtml :: String [BodyTag] *HSt -> (Html,*HSt) // string is used for the title of the page
mkHtmlB :: String [BodyAttr] [BodyTag] *HSt -> (Html,*HSt) // same, with bodytags options
simpleHtml :: String [BodyAttr] [BodyTag] -> Html // as above, without HSt
mkHtml :: String [BodyTag] *HSt -> (Html,*HSt) // string is used for the title of the page
mkHtmlB :: String [BodyAttr] [BodyTag] *HSt -> (Html,*HSt) // same, with bodytags options
simpleHtml :: String [BodyAttr] [BodyTag] -> Html // as above, without HSt
// **** LayOut support ****
(<=>) infixl 5 :: [BodyTag] [BodyTag] -> BodyTag // place next to each other on a page
(<.=.>) infixl 5 :: BodyTag BodyTag -> BodyTag // place next to each other on a page
mkRowForm :: [BodyTag] -> BodyTag // place every element in a row next to each other on a page
(<=>) infixl 5 :: [BodyTag] [BodyTag] -> BodyTag // place next to each other on a page
(<.=.>) infixl 5 :: BodyTag BodyTag -> BodyTag // place next to each other on a page
mkRowForm :: ![BodyTag] -> BodyTag // place every element in a row next to each other on a page
(<||>) infixl 4 :: [BodyTag] [BodyTag] -> BodyTag // Place second below first
(<.||.>) infixl 4 :: BodyTag BodyTag -> BodyTag // Place second below first
(<|.|>) infixl 4 :: [BodyTag] [BodyTag] -> [BodyTag] // Place second below first
mkColForm :: [BodyTag] -> BodyTag // Place every element in a column below first
(<||>) infixl 4 :: [BodyTag] [BodyTag] -> BodyTag // Place second below first
(<.||.>) infixl 4 :: BodyTag BodyTag -> BodyTag // Place second below first
(<|.|>) infixl 4 :: [BodyTag] [BodyTag] -> [BodyTag] // Place second below first
mkColForm :: ![BodyTag] -> BodyTag // Place every element in a column below first
mkSTable :: [[BodyTag]] -> BodyTag // Make a table, default with
mkTable :: [[BodyTag]] -> BodyTag // Make a table
(<=|>) infixl 4 :: [BodyTag] [BodyTag] -> BodyTag // Make a table by putting elements pairwise below each other
mkSTable :: [[BodyTag]] -> BodyTag // Make a table, default with
mkTable :: [[BodyTag]] -> BodyTag // Make a table
(<=|>) infixl 4 :: [BodyTag] [BodyTag] -> BodyTag // Make a table by putting elements pairwise below each other
// **** frquently used "mkViewForm" variants ****
......@@ -36,90 +36,91 @@ mkTable :: [[BodyTag]] -> BodyTag // Make a table
// mkSubState : makes form for substate, with ok and cancel buttons; only added to state if ok is pressed
// mkShowHide : as mkEdit, but with show / hide button
mkBimapEditor :: !(InIDataId d) !(Bimap d v) !*HSt -> (Form d,!*HSt) | iData v
mkEditForm :: !(InIDataId d) !*HSt -> (Form d,!*HSt) | iData d
mkStoreForm :: !(InIDataId d) !(d -> d) !*HSt -> (Form d,!*HSt) | iData d
mkSelfForm :: !(InIDataId d) !(d -> d) !*HSt -> (Form d,!*HSt) | iData d
mkApplyEditForm :: !(InIDataId d) !d !*HSt -> (Form d,!*HSt) | iData d
mkBimapEditor :: !(InIDataId d) !(Bimap d v) !*HSt -> (Form d,!*HSt) | iData v
mkEditForm :: !(InIDataId d) !*HSt -> (Form d,!*HSt) | iData d
mkStoreForm :: !(InIDataId d) !(d -> d) !*HSt -> (Form d,!*HSt) | iData d
mkSelfForm :: !(InIDataId d) !(d -> d) !*HSt -> (Form d,!*HSt) | iData d
mkApplyEditForm :: !(InIDataId d) !d !*HSt -> (Form d,!*HSt) | iData d
mkSubStateForm :: !(InIDataId !subState) !state !(subState state -> state) !*HSt -> (Bool,Form state,!*HSt)
| iData subState
mkSubStateForm :: !(InIDataId subState) !state !(subState state -> state)
!*HSt -> (Bool,Form state,!*HSt)
| iData subState
mkShowHideForm :: !(InIDataId a) !*HSt -> (Form a,!*HSt) | iData a
mkShowHideForm :: !(InIDataId a) !*HSt -> (Form a,!*HSt) | iData a
// **** forms for lists ****
listForm :: !(InIDataId [a]) !*HSt -> (Form [a],!*HSt) | iData a
horlistForm :: !(InIDataId [a]) !*HSt -> (Form [a],!*HSt) | iData a
vertlistForm :: !(InIDataId [a]) !*HSt -> (Form [a],!*HSt) | iData a
table_hv_Form :: !(InIDataId [[a]]) !*HSt -> (Form [[a]],!*HSt) | iData a
layoutListForm :: !([BodyTag] [BodyTag] -> [BodyTag])
!(!(InIDataId a) !*HSt -> (Form a,*HSt))
!(InIDataId [a]) !*HSt -> (Form [a],!*HSt) | iData a
listForm :: !(InIDataId [a]) !*HSt -> (Form [a],!*HSt) | iData a
horlistForm :: !(InIDataId [a]) !*HSt -> (Form [a],!*HSt) | iData a
vertlistForm :: !(InIDataId [a]) !*HSt -> (Form [a],!*HSt) | iData a
table_hv_Form :: !(InIDataId [[a]]) !*HSt -> (Form [[a]],!*HSt) | iData a
layoutListForm :: !([BodyTag] [BodyTag] -> [BodyTag])
!((InIDataId a) *HSt -> (Form a,*HSt))
!(InIDataId [a]) !*HSt -> (Form [a],!*HSt) | iData a
// User controlled number of list elements will be shown, including optional delete and append buttons; Int indicates max number of browse buttons
vertlistFormButs:: !Int !Bool !(InIDataId [a]) !*HSt -> (Form [a],!*HSt) | iData a
vertlistFormButs :: !Int !Bool !(InIDataId [a]) !*HSt -> (Form [a],!*HSt) | iData a
// **** forms for tuples ****
t2EditForm :: !(InIDataId (a,b)) !*HSt -> ((Form a,Form b),!*HSt)| iData a & iData b
t3EditForm :: !(InIDataId (a,b,c)) !*HSt -> ((Form a,Form b,Form c),!*HSt)
| iData a & iData b & iData c
t4EditForm :: !(InIDataId (a,b,c,d)) !*HSt -> ((Form a,Form b,Form c,Form d),!*HSt)
| iData a & iData b & iData c & iData d
t2EditForm :: !(InIDataId (a,b)) !*HSt -> ((Form a,Form b),!*HSt)
| iData a & iData b
t3EditForm :: !(InIDataId (a,b,c)) !*HSt -> ((Form a,Form b,Form c),!*HSt)
| iData a & iData b & iData c
t4EditForm :: !(InIDataId (a,b,c,d)) !*HSt -> ((Form a,Form b,Form c,Form d),!*HSt)
| iData a & iData b & iData c & iData d
// **** special buttons ****
counterForm :: !(InIDataId a) !*HSt -> (Form a,!*HSt) | +, -, one, iData a
counterForm :: !(InIDataId a) !*HSt -> (Form a,!*HSt) | +, -, one, iData a
// buttons returning index between 1 to n given stepsize, n, maximal numberofbuttuns to show
browseButtons :: !(InIDataId !Int) !Int !Int !Int !*HSt -> (Form Int,!*HSt)
browseButtons :: !(InIDataId Int) !Int !Int !Int !*HSt -> (Form Int,!*HSt)
// **** to each button below a function is assigned which is returned as iData value when the corresponding button is pressed
// **** an identity function is returned when none of the set of buttons pressed
simpleButton :: !String !String !(a -> a) !*HSt -> (Form (a -> a),!*HSt)
FuncBut :: !(InIDataId (Button, a -> a)) !*HSt -> (Form (a -> a),!*HSt)
ListFuncBut :: !(InIDataId [(Button, a -> a)]) !*HSt -> (Form (a -> a),!*HSt)
TableFuncBut :: !(InIDataId [[(Button, a -> a)]]) !*HSt -> (Form (a -> a),!*HSt)
simpleButton :: !String !String !(a -> a) !*HSt -> (Form (a -> a),!*HSt)
FuncBut :: !(InIDataId (Button, a -> a)) !*HSt -> (Form (a -> a),!*HSt)
ListFuncBut :: !(InIDataId [(Button, a -> a)]) !*HSt -> (Form (a -> a),!*HSt)
TableFuncBut :: !(InIDataId [[(Button,a -> a)]]) !*HSt -> (Form (a -> a),!*HSt)
//fine grain variant, mode of each button in list or table can be set
ListFuncBut2 :: !(InIDataId [(Mode,Button, a -> a)]) !*HSt -> (Form (a -> a),!*HSt)
TableFuncBut2 :: !(InIDataId [[(Mode,Button, a -> a)]]) !*HSt -> (Form (a -> a),!*HSt)
ListFuncBut2 :: !(InIDataId [(Mode,Button, a -> a)]) !*HSt -> (Form (a -> a),!*HSt)
TableFuncBut2 :: !(InIDataId [[(Mode,Button, a -> a)]]) !*HSt -> (Form (a -> a),!*HSt)
// assign function to each check box which gets an integer of the selected box and the settings of all other boxes
// in addition to the chosen function the settings of all check boxes is returned
ListFuncCheckBox:: !(InIDataId [(CheckBox, Bool [Bool] a -> a)]) !*HSt -> (Form (a -> a,[Bool]),!*HSt)
ListFuncCheckBox :: !(InIDataId [(CheckBox,Bool [Bool] a -> a)]) !*HSt -> (Form (a -> a,[Bool]),!*HSt)
// assign function to each radio button which gets an integer of the selected radio
// in addition to the chosen function an integer indicating the selected radio button is returned
ListFuncRadio :: !(InIDataId (Int,[Int a -> a])) !*HSt -> (Form (a -> a,Int),!*HSt)
ListFuncRadio :: !(InIDataId (Int,[Int a -> a])) !*HSt -> (Form (a -> a,Int),!*HSt)
// assign function to each pull down menu which gets an integer of the selected menu element
// in addition to the chosen function an integer indicating the selected menu item is returned
FuncMenu :: !(InIDataId (Int,[(String, a -> a)])) !*HSt -> (Form (a -> a,Int),!*HSt)
FuncMenu :: !(InIDataId (Int,[(String, a -> a)])) !*HSt -> (Form (a -> a,Int),!*HSt)
// **** special objects ****
mediaPlayer :: (Int,Int) Bool String -> BodyTag // plays movies, music etc; parameters (height,width) autostart filename
MailForm :: String Int Int -> BodyTag // mailadddres, row size, col size
MailApplicationLink :: String String String -> BodyTag // Link will start mail application: mailadddres, subject, contensbody
mediaPlayer :: !(Int,Int) Bool String -> BodyTag // plays movies, music etc; parameters (height,width) autostart filename
MailForm :: String Int Int -> BodyTag // mailadddres, row size, col size
MailApplicationLink :: String String String -> BodyTag // Link will start mail application: mailadddres, subject, contensbody
// **** scripts ****
// openWindowScript will open a new browser window displaying the html code
// parameters resp: scriptname() height width toolbar menubar scrollbars resizable location status html
openWindowScript :: !String !Int !Int !Bool !Bool !Bool !Bool !Bool !Bool !Html -> Script
openWindowScript :: !String !Int !Int !Bool !Bool !Bool !Bool !Bool !Bool !Html -> Script
// openNoticeScript simplified version of openWindowScript
// parameters are resp: scriptname() height width html
openNoticeScript :: !String !Int !Int !Html -> Script
openNoticeScript :: !String !Int !Int !Html -> Script
OnLoadException :: (Bool,String) -> [BodyAttr] // to produce message on opening page
OnLoadException :: !(!Bool,String) -> [BodyAttr] // to produce message on opening page
This diff is collapsed.
......@@ -5,52 +5,49 @@ definition module htmlHandler
import htmlDataDef, htmlFormData, htmlSettings
import StdBool
import GenPrint
import GenParse
import Gerda
generic gForm a :: !(InIDataId a) !*HSt -> *(Form a, !*HSt) // user defined gForms: use "specialize"
generic gUpd a :: UpdMode a -> (UpdMode,a) // gUpd can simply be derived
generic gForm a :: !(InIDataId a) !*HSt -> *(Form a, !*HSt) // user defined gForms: use "specialize"
generic gUpd a :: UpdMode a -> (UpdMode,a) // gUpd can simply be derived
import GenPrint
import GenParse
import Gerda
derive gForm Int, Real, Bool, String, UNIT, PAIR, EITHER, OBJECT, CONS, FIELD//, (,)
derive gUpd Int, Real, Bool, String, UNIT, PAIR, EITHER, OBJECT, CONS, FIELD//, (,)
derive gForm Int, Real, Bool, String, UNIT, PAIR, EITHER, OBJECT, CONS, FIELD
derive gUpd Int, Real, Bool, String, UNIT, PAIR, EITHER, OBJECT, CONS, FIELD
derive bimap Form, FormId
:: *HSt = { cntr :: Int // counts position in expression
, states :: *FormStates // all form states are collected here ...
, world :: *NWorld // to enable file I/O, database I/O, ...
}
:: *HSt = { cntr :: Int // counts position in expression
, states :: *FormStates // all form states are collected here ...
, world :: *NWorld // to enable file I/O, database I/O, ...
}
// doHtml main wrapper for generating & handling of a Html form
doHtml :: .(*HSt -> (Html,!*HSt)) *World -> *World // use this application with some external server and php
doHtmlServer :: (*HSt -> (Html,!*HSt)) *World -> *World // use this application with the build-in Clean server: http://localhost/clean
// mkViewForm is the *swiss army nife* function creating stateful interactive forms with a view v of data d
// make shure that all editors have a unique identifier !
doHtml :: !.(*HSt -> (Html,!*HSt)) !*World -> *World // use this application with some external server and php
doHtmlServer :: ! (*HSt -> (Html,!*HSt)) !*World -> *World // use this application with the build-in Clean server: http://localhost/clean
mkViewForm :: !(InIDataId d) !(HBimap d v) !*HSt -> (Form d,!*HSt) | iData v
//mkViewForm :: !(InIDataId d) !(HBimap d v) !*HSt -> (Form d,!*HSt) | gForm{|*|}, gUpd{|*|}, gPrint{|*|}, gParse{|*|}, gerda{|*|}, TC v
// mkViewForm is the *swiss army knife* function creating stateful interactive forms with a view v of data d.
// Make sure that all editors have a unique identifier!
mkViewForm :: !(InIDataId d) !(HBimap d v) !*HSt -> (Form d,!*HSt) | iData v
// specialize has to be used if one wants to specialize gForm for a user-defined type
specialize :: !(!(InIDataId a) !*HSt -> (!Form a,!*HSt)) !(InIDataId a) !*HSt -> (!Form a,!*HSt) | gUpd {|*|} a
specialize :: !((InIDataId a) *HSt -> (Form a,*HSt)) !(InIDataId a) !*HSt -> (!Form a,!*HSt) | gUpd {|*|} a
// utility functions
toHtml :: a -> BodyTag | gForm {|*|} a // toHtml displays any type into a non-editable form
toHtmlForm :: (*HSt -> *(Form a,*HSt)) -> [BodyTag] // toHtmlForm displays any form one can make with a form function
toHtml :: a -> BodyTag | gForm {|*|} a // toHtml displays any type into a non-editable form
toHtmlForm :: !(*HSt -> *(Form a,*HSt)) -> [BodyTag] // toHtmlForm displays any form one can make with a form function
| gForm{|*|}, gUpd{|*|}, gPrint{|*|}, gParse{|*|}, TC a
toBody :: (Form a) -> BodyTag // just (BodyTag form.body)
createDefault :: a | gUpd{|*|} a // creates a default value of requested type
toBody :: (Form a) -> BodyTag // just (BodyTag form.body)
createDefault :: a | gUpd{|*|} a // creates a default value of requested type
// definitions on HSt
instance FileSystem HSt // enabling file IO on HSt
instance FileSystem HSt // enabling file IO on HSt
appWorldHSt :: !.(*World -> *World) !*HSt -> *HSt // enabling World operations on HSt
accWorldHSt :: !.(*World -> *(.a,*World)) !*HSt -> (.a,!*HSt) // enabling World operations on HSt
appWorldHSt :: !.(*World -> *World) !*HSt -> *HSt // enabling World operations on HSt
accWorldHSt :: !.(*World -> *(.a,*World)) !*HSt -> (.a,!*HSt) // enabling World operations on HSt
// Specialists section...
......@@ -59,16 +56,15 @@ accWorldHSt :: !.(*World -> *(.a,*World)) !*HSt -> (.a,!*HSt) // enabling World
import iDataState
runUserApplication :: .(*HSt -> *(.a,*HSt)) *FormStates *NWorld -> *(.a,*FormStates,*NWorld)
runUserApplication :: .(*HSt -> *(.a,*HSt)) *FormStates *NWorld -> *(.a,*FormStates,*NWorld)
// Some low level utility functions handy when specialize cannot be used, only to be used by experts !!
incrHSt :: Int *HSt -> *HSt // Cntr := Cntr + 1
CntrHSt :: *HSt -> (Int,*HSt) // Hst.Cntr
mkInput :: !Int !(InIDataId d) Value UpdValue *HSt -> (BodyTag,*HSt) // Html Form Creation utility
getChangedId :: !*HSt -> (String,!*HSt) // id of form that has been changed by user
:: UpdMode = UpdSearch UpdValue Int // search for indicated postion and update it
| UpdCreate [ConsPos] // create new values if necessary
| UpdDone // and just copy the remaining stuff
incrHSt :: Int !*HSt -> *HSt // Cntr := Cntr + 1
CntrHSt :: !*HSt -> (Int,*HSt) // Hst.Cntr
mkInput :: !Int !(InIDataId d) Value UpdValue !*HSt -> (BodyTag,*HSt) // Html Form Creation utility
getChangedId :: !*HSt -> (String,!*HSt) // id of form that has been changed by user
:: UpdMode = UpdSearch UpdValue Int // search for indicated postion and update it
| UpdCreate [ConsPos] // create new values if necessary
| UpdDone // and just copy the remaining stuff
This diff is collapsed.
......@@ -10,7 +10,7 @@ import StdEnv, htmlHandler, htmlButtons
instance == (Ref2 a)
ref2EditForm :: !(InIDataId a) !(InIDataId (Ref2 a)) !*HSt -> (Form a,!*HSt) | iData a
invokeRefEditor :: (!(InIDataId b) !*HSt -> (Form d,!*HSt)) (InIDataId b) !*HSt -> (Form b,!*HSt)
invokeRefEditor :: !((InIDataId b) *HSt -> (Form d,*HSt)) (InIDataId b) !*HSt -> (Form b,!*HSt)
universalRefEditor :: !Lifespan !(InIDataId (Ref2 a)) !(a -> Judgement) !*HSt -> (Form a,!*HSt) | iData a
......
......@@ -23,7 +23,7 @@ ref2EditForm (inita,formida) (_,{ival=Ref2 refname}) hst
| refname == "" = mkEditForm (Init,reuseFormId formida createDefault) hst
| otherwise = mkEditForm (inita,{formida & id = refname}) hst
invokeRefEditor :: (!(InIDataId b) !*HSt -> (Form d,!*HSt)) (InIDataId b) !*HSt -> (Form b,!*HSt)
invokeRefEditor :: !((InIDataId b) *HSt -> (Form d,*HSt)) (InIDataId b) !*HSt -> (Form b,!*HSt)
invokeRefEditor editor (init,formid) hst
# (idata,hst) = editor (init,formid) hst
= ({idata & value = formid.ival},hst)
......
......@@ -6,10 +6,12 @@ derive bimap Maybe, (,)
// utility
mkString :: [Char] -> *String
mkList :: String -> [Char]
mkString :: ![Char] -> *String
mkList :: !String -> [Char]
// Useful string concatenation function
(<+++) infixl :: !String !a -> String | toString a
(??) infixl 9 :: ![a] !a -> Int | == a
const2 :: .a !.b -> .b
......@@ -6,11 +6,11 @@ derive bimap Maybe, (,)
// converting strings to lists and backwards
mkString :: [Char] -> *String
mkString listofchar = {c \\ c <- listofchar }
mkString :: ![Char] -> *String
mkString listofchar = {c \\ c <- listofchar }
mkList :: String -> [Char]
mkList string = [c \\ c <-: string ]
mkList :: !String -> [Char]
mkList string = [c \\ c <-: string ]
// Useful string concatenation function
(<+++) infixl :: !String !a -> String | toString a
......@@ -22,3 +22,6 @@ mkList string = [c \\ c <-: string ]
| otherwise = 1 + as??b
(??) [] _
= -1
const2 :: .a !.b -> .b
const2 _ x = x
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment