Commit 5058bb79 authored by Rinus Plasmeijer's avatar Rinus Plasmeijer
Browse files

*** empty log message ***

parent a5780c38
......@@ -16,10 +16,13 @@ derive gPrint Void
derive gerda Void
/* Initiating the iTask library:
startTask :: start function for iTasks for user with indicated id
startTask :: general start function for iTasks for user with indicated id
singleUserTask :: wrapper for single user
multiUserTask :: wrapper for [0..users - 1], optional set of global Task attributes can be given
*/
startTask :: !Int !(Task a) HSt -> (a,[BodyTag],HSt) | iData a
singleUserTask :: !(Task a) !*HSt -> (Html,*HSt) | iData a
multiUserTask :: !Int !(Task a) [*TSt -> *TSt] !*HSt -> (Html,*HSt) | iData a
/* Global Attribute settings: iTask are by default Lifespan = Session, StorageFormt = PlainString
For multi user systems
*/
......@@ -34,6 +37,7 @@ instance setTaskAttribute Lifespan, StorageFormat
/* Promote any TSt state transition function to an iTask:
mkTask :: function will only be called when it is its turn to be activated
Also needed for defining recursive tasks
clearTask :: same, but clear output of all finished recursive calls
*/
mkTask :: (*TSt -> *(a,*TSt)) -> (Task a) | iData a
......@@ -80,11 +84,13 @@ returnV :: return the value
returnTask :: return the value and show it
returnVF :: return the value and show the Html code specified
returnF :: add html code
(?>>) :: only prompt as long as task is active but not finished
*/
returnV :: a -> (Task a) | iData a
returnTask :: a -> (Task a) | iData a
returnVF :: a [BodyTag] -> (Task a) | iData a
returnF :: [BodyTag] -> TSt -> TSt
(?>>) infix 3 :: [BodyTag] v:(St TSt .a) -> v:(St TSt .a)
/* Setting up communication channels between users:
mkRTask :: Remote Task: split indicated task in two tasks: a calling task and a receiving task
......
......@@ -61,6 +61,23 @@ where setTaskAttribute lifespan tst = {tst & storageInfo.tasklife = lifespan}
instance setTaskAttribute StorageFormat
where setTaskAttribute storageformat tst = {tst & storageInfo.taskstorage = storageformat}
singleUserTask :: !(Task a) !*HSt -> (Html,*HSt) | iData a
singleUserTask task hst
# (_,html,hst) = startTask 0 task hst
= mkHtml "stest" html hst
multiUserTask :: !Int !(Task a) [*TSt -> *TSt] !*HSt -> (Html,*HSt) | iData a
multiUserTask nusers task attr hst
# (idform,hst) = FuncMenu (Init,nFormId "pdm_chooseWorker"
(0,[("User " +++ toString i,\_ -> i) \\ i<-[0..nusers - 1] ])) hst
# currentWorker = snd idform.value
# (_,html,hst) = startTask currentWorker (applyattr task) hst
= mkHtml "mtest" [idform.form <=> html] hst
where
applyattr task tst
# tst = seq attr tst
= task tst
(@:) infix 0 :: !(!Int,!String) (Task a) -> (Task a) | iData a
(@:) (userId,taskname) taska = \tst -> mkTask assignTask` tst
where
......@@ -457,6 +474,13 @@ showMine bool html more = if bool (html +|+ more) html
(#>>) infix 1 :: w:(St .s .a) v:(St .s .b) -> u:(St .s .b), [u <= v, u <= w]
(#>>) a b = a `bind` (\_ -> b)
(?>>) infix 3 :: [BodyTag] v:(St TSt .a) -> v:(St TSt .a)
(?>>) prompt task = \tst -> doit tst
where
doit tst=:{html=ohtml,activated=myturn}
# (a,tst=:{activated,html=nhtml}) = task {tst & html = BT []}
| activated || not myturn= (a,{tst & html = ohtml +|+ nhtml})
= (a,{tst & html = ohtml +|+ BT prompt +|+ nhtml})
// debugging code
......
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