Commit b43b976d authored by Rinus Plasmeijer's avatar Rinus Plasmeijer

*** empty log message ***


git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@118 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 1ad78ff2
......@@ -66,7 +66,6 @@ workFlowTask :: ![StartUpOptions] !(Task (UserId,a))
| VersionCheck | NoVersionCheck // for single & multiUser: default = VersionNoCheck
| MyHeader HtmlCode // wil replace standard iTask information line
// *********************************************************************************************************************************
/* Here follow the iTasks combinators:
......@@ -83,15 +82,12 @@ Prompting variants:
(!>>) :: prompt when task is activated
(<<?) :: as ?>>, except that prompt is displayed *after* task
(<<!) :: as !>>, except that prompt is displayed *after* task
return_VF :: return the value and show the Html code specified
return_D :: return the value and show it in iData display format
Assign tasks to user with indicated id:
assignTaskTo :: assign task to indicated user, True for verbose reporting
Repetition and loops:
foreverTask :: infinitely repeating Task
(<|) :: repeat task (recursively) as long as predicate does not hold, and give error message otherwise
(<!) :: repeat task (as a loop) as long as predicate does not hold; also works for tasks that don't require any user interactions (e.g. database access)
Sequencing Tasks:
......@@ -121,13 +117,10 @@ return_V :: !a -> Task a | iCreateAndPrint a
(!>>) infixr 5 :: !HtmlCode !(Task a) -> Task a | iCreate a
(<<?) infixl 5 :: !(Task a) !HtmlCode -> Task a | iCreate a
(<<!) infixl 5 :: !(Task a) !HtmlCode -> Task a | iCreate a
return_VF :: !HtmlCode !a -> Task a | iCreateAndPrint a
return_D :: !a -> Task a | gForm {|*|}, iCreateAndPrint a
assignTaskTo :: !Bool !UserId !(LabeledTask a) -> Task a | iData a
foreverTask :: !(Task a) -> Task a | iData a
(<|) infixl 6 :: !(Task a) !(a -> (Bool, HtmlCode)) -> Task a | iCreate a
(<!) infixl 6 :: !(Task a) !(a -> .Bool) -> Task a | iCreateAndPrint a
seqTasks :: ![LabeledTask a] -> Task [a] | iCreateAndPrint a
......@@ -139,7 +132,7 @@ chooseTask_radio:: !HtmlCode !Int ![(HtmlCode,LabeledTask a)]
:: ChoiceUpdate :== !Bool [Bool] -> [Bool] // changed checkbox + current settings -> new settings
chooseTask_cb :: !([LabeledTask a] -> Task [a])
chooseTask_cbox :: !([LabeledTask a] -> Task [a])
!HtmlCode ![((!Bool,!ChoiceUpdate,!HtmlCode),LabeledTask a)]
-> Task [a] | iData a
......
......@@ -1046,21 +1046,7 @@ where
return_V :: !a -> (Task a) | iCreateAndPrint a
return_V a = mkTask "return_V" dotask
where
dotask tst = (a,{tst & activated = True})
// monads variant which show information
return_D :: !a -> (Task a) | gForm {|*|}, iCreateAndPrint a
return_D a = mkTask "return_D" return_Display`
where
return_Display` tst
= (a,{tst & html = tst.html +|+ BT [toHtml a ]}) // return result task
return_VF :: !HtmlCode !a -> (Task a) | iCreateAndPrint a
return_VF bodytag a = mkTask "return_VF" return_VF`
where
return_VF` tst
= (a,{tst & html = tst.html +|+ BT bodytag})
dotask tst = (a,tst)
// ******************************************************************************************************
// adding Html code for prompting and feedback
......@@ -1099,15 +1085,6 @@ where
# (a,tst=:{html=nhtml}) = task {tst & html = BT []}
= (a,{tst & html = ohtml +|+ nhtml +|+ BT prompt})
(<|) infixl 6 :: !(Task a) !(a -> (Bool, HtmlCode)) -> Task a | iCreate a
(<|) taska pred = doTask
where
doTask tst=:{html = ohtml,activated}
| not activated = (createDefault,tst)
# (a,tst=:{activated,html= nhtml}) = taska {tst & html = BT []}
| not activated || fst (pred a) = (a,{tst & html = ohtml +|+ nhtml})
= doTask {tst & html = ohtml +|+ BT (snd (pred a))}
// ******************************************************************************************************
// newTask needed for recursive task creation
......@@ -1148,17 +1125,6 @@ where
= foreverTask` {tst & tasknr = tasknr, options = options, html = html} // initialize new task
= (val,tst)
repeatTask :: !(a -> Task a) !(a -> Bool) a -> Task a | iData a
repeatTask task pred a = dorepeatTask a
where
dorepeatTask a
= newTask "doReapeatTask" dorepeatTask`
where
dorepeatTask` tst
| pred a = (a,tst)
# (na,tst) = task a tst
= dorepeatTask na tst
(<!) infixl 6 :: !(Task a) !(a -> .Bool) -> Task a | iCreateAndPrint a
(<!) taska pred = mkTask "less!" doTask
where
......@@ -1302,8 +1268,8 @@ where
= chosenTask {tst & activated = True, html = BT [], tasknr = [0:tasknr]}
= (a,{tst & activated = adone, html = html +|+ ahtml, tasknr = tasknr})
chooseTask_cb :: !([LabeledTask a] -> Task [a]) !HtmlCode ![((!Bool,!ChoiceUpdate,!HtmlCode),LabeledTask a)] -> Task [a] | iData a
chooseTask_cb taskorderfun prompt taskOptions = mkTask "mchoiceTask" (domchoiceTasks taskOptions)
chooseTask_cbox :: !([LabeledTask a] -> Task [a]) !HtmlCode ![((!Bool,!ChoiceUpdate,!HtmlCode),LabeledTask a)] -> Task [a] | iData a
chooseTask_cbox taskorderfun prompt taskOptions = mkTask "mchoiceTask" (domchoiceTasks taskOptions)
where
domchoiceTasks [] tst = ([],{tst& activated = True})
domchoiceTasks taskOptions tst=:{tasknr,html,options,userId} // choose one subtask out of the list
......
......@@ -10,8 +10,12 @@ import iTasks
/* standard monadic combinators on iTasks:
(#>>) :: for sequencing: bind, but no argument passed
return_D :: return the value and show it in iData display format
return_VF :: return the value and show the Html code specified
*/
(#>>) infixl 1 :: !(Task a) !(Task b) -> Task b | iCreateAndPrint b
return_D :: !a -> Task a | gForm {|*|}, iCreateAndPrint a
return_VF :: !HtmlCode !a -> Task a | iCreateAndPrint a
/* Assign tasks to user with indicated id:
(@:) :: will prompt who is waiting for task with give name
......@@ -26,10 +30,13 @@ import iTasks
/* Handling recursion and loops:
repeatTask :: repeat Task until predicate is valid
(<|) :: repeat task (recursively) as long as predicate does not hold, and give error message otherwise
*/
repeatTask :: !(a -> Task a) !(a -> Bool) a -> Task a | iData a
(<|) infixl 6 :: !(Task a) !(a -> (Bool, HtmlCode)) -> Task a | iData a
/* Choose out the tasks you want to do one forehand, labels are used to make the choice:
button :: return value when button pressed
buttonTask :: do the iTask when button pressed
chooseTask :: Choose ONE iTask from list, depending on button pressed, button horizontal displayed
chooseTaskV :: as chooseTask, buttons vertical displayed
......@@ -43,6 +50,7 @@ mchoiceTask2 :: as mchoiceTask, boolean used for initial setting of the checks
mchoiceTask3 :: as mchoiceTask2, function can be used to (re)set the checkboxes
*/
button :: !String !a -> Task a | iCreateAndPrint a
buttonTask :: !String !(Task a) -> Task a | iCreateAndPrint a
chooseTask :: !HtmlCode ![LabeledTask a] -> Task a | iCreateAndPrint a
chooseTaskV :: !HtmlCode ![LabeledTask a] -> Task a | iCreateAndPrint a
......
......@@ -19,6 +19,12 @@ derive gUpd []
= taska
=>> \_ -> taskb
return_VF :: !HtmlCode !a -> (Task a) | iCreateAndPrint a
return_VF bodytag a = return_V a <<! bodytag
return_D :: !a -> (Task a) | gForm {|*|}, iCreateAndPrint a
return_D a = return_V a <<! [toHtml a ]
// ******************************************************************************************************
// repetition
......@@ -33,6 +39,16 @@ where
# (na,tst) = task a tst
= dorepeatTask na tst
(<|) infixl 6 :: !(Task a) !(a -> (Bool, HtmlCode)) -> Task a | iData a
(<|) taska pred = mkTask "repeatTest" doTask
where
doTask
= taska
=>> \r -> case pred r of
(True,_) -> return_V r
(False,msg) -> msg ?>> doTask
// ******************************************************************************************************
// Assigning tasks to users, each user has to be identified by an unique number >= 0
......@@ -51,6 +67,9 @@ where
// ******************************************************************************************************
// choose one or more tasks on forehand out of a set
button :: !String !a -> (Task a) | iCreateAndPrint a
button s a = mkTask "button" (chooseTask_btn [] True [(s,return_V a)])
buttonTask :: !String !(Task a) -> (Task a) | iCreateAndPrint a
buttonTask s task = mkTask "buttonTask" (chooseTask_btn [] True [(s,task)])
......@@ -62,27 +81,27 @@ chooseTaskV prompt options = mkTask "chooseTask" (chooseTask_btn prompt False op
mchoiceTasks :: !HtmlCode ![LabeledTask a] -> (Task [a]) | iData a
mchoiceTasks prompt taskOptions
= mpchoiceTasks seqTasks prompt [((False,\b bs -> bs,[]),labeltask) \\ labeltask <- taskOptions]
= chooseTask_cbox seqTasks prompt [((False,\b bs -> bs,[]),labeltask) \\ labeltask <- taskOptions]
mchoiceTasks2 :: !HtmlCode ![(!Bool,LabeledTask a)] -> Task [a] | iData a
mchoiceTasks2 prompt taskOptions
= mpchoiceTasks seqTasks prompt [((set,\b bs -> bs,[]),labeltask) \\ (set,labeltask) <- taskOptions]
= chooseTask_cbox seqTasks prompt [((set,\b bs -> bs,[]),labeltask) \\ (set,labeltask) <- taskOptions]
mchoiceTasks3 :: !HtmlCode ![((!Bool,!ChoiceUpdate,!HtmlCode),LabeledTask a)] -> Task [a] | iData a
mchoiceTasks3 prompt taskOptions
= mpchoiceTasks seqTasks prompt taskOptions
= chooseTask_cbox seqTasks prompt taskOptions
mchoiceAndTasks :: !HtmlCode ![LabeledTask a] -> (Task [a]) | iData a
mchoiceAndTasks prompt taskOptions
= mpchoiceTasks andTasks prompt [((False,\b bs -> bs,[]),labeltask) \\ labeltask <- taskOptions]
= chooseTask_cbox andTasks prompt [((False,\b bs -> bs,[]),labeltask) \\ labeltask <- taskOptions]
mchoiceAndTasks2 :: !HtmlCode ![(!Bool,LabeledTask a)] -> Task [a] | iData a
mchoiceAndTasks2 prompt taskOptions
= mpchoiceTasks andTasks prompt [((set,\b bs -> bs,[]),labeltask) \\ (set,labeltask) <- taskOptions]
= chooseTask_cbox andTasks prompt [((set,\b bs -> bs,[]),labeltask) \\ (set,labeltask) <- taskOptions]
mchoiceAndTasks3 :: !HtmlCode ![((!Bool,!ChoiceUpdate,!HtmlCode),LabeledTask a)] -> Task [a] | iData a
mchoiceAndTasks3 prompt taskOptions
= mpchoiceTasks andTasks prompt taskOptions
= chooseTask_cbox andTasks prompt taskOptions
// ******************************************************************************************************
// Speculative OR-tasks: task ends as soon as one of its subtasks completes
......
Markdown is supported
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