Commit 8d26a3d1 authored by Bas Lijnse's avatar Bas Lijnse

Emergency fix for previously impossible pattern in step, we must discuss...

Emergency fix for previously impossible pattern in step, we must discuss whether this needs to be rolled back after the Incidone demo

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@2641 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 943d6478
......@@ -14,19 +14,19 @@ from Data.Map import qualified put
import iTasks.API.Core.CoreTasks, iTasks.API.Core.CoreCombinators, iTasks.API.Common.InteractionTasks, iTasks.API.Core.LayoutCombinators
(>>*) infixl 1 :: !(Task a) ![TaskStep a b] -> Task b | iTask a & iTask b
(>>*) task steps = step task steps
(>>*) task steps = step task (const Nothing) steps
(>>=) infixl 1 :: !(Task a) !(a -> Task b) -> Task b | iTask a & iTask b
(>>=) taska taskbf = step taska [OnAction ActionContinue (hasValue taskbf), OnValue (ifStable taskbf)]
(>>=) taska taskbf = step taska (const Nothing) [OnAction ActionContinue (hasValue taskbf), OnValue (ifStable taskbf)]
(>>!) infixl 1 :: !(Task a) !(a -> Task b) -> Task b | iTask a & iTask b
(>>!) taska taskbf = step taska [OnAction ActionContinue (hasValue taskbf)]
(>>!) taska taskbf = step taska (const Nothing) [OnAction ActionContinue (hasValue taskbf)]
(>>-) infixl 1 :: !(Task a) !(a -> Task b) -> Task b | iTask a & iTask b
(>>-) taska taskbf = step taska [OnValue (ifStable taskbf)]
(>>-) taska taskbf = step taska (const Nothing) [OnValue (ifStable taskbf)]
(>>|) infixl 1 :: !(Task a) (Task b) -> Task b | iTask a & iTask b
(>>|) taska taskb = step taska [OnAction ActionContinue (hasValue (const taskb)), OnValue (ifStable (const taskb))]
(>>|) taska taskb = step taska (const Nothing) [OnAction ActionContinue (hasValue (const taskb)), OnValue (ifStable (const taskb))]
(>>^) infixl 1 :: !(Task a) (Task b) -> Task a | iTask a & iTask b
(>>^) taska taskb = taska >>= \x -> taskb >>| return x
......@@ -53,10 +53,10 @@ import iTasks.API.Core.CoreTasks, iTasks.API.Core.CoreCombinators, iTasks.API.Co
(@@>) a t = tunev a t
try :: !(Task a) (e -> Task a) -> Task a | iTask a & iTask, toString e
try task handler = step task [OnValue (ifStable return), OnException handler]
try task handler = step task id [OnValue (ifStable return), OnException handler]
catchAll :: !(Task a) (String -> Task a) -> Task a | iTask a
catchAll task handler = step task [OnValue (ifStable return), OnAllExceptions handler]
catchAll task handler = step task id [OnValue (ifStable return), OnAllExceptions handler]
(>^*) infixl 1 :: !(Task a) ![TaskStep a b] -> Task a | iTask a & iTask b
(>^*) task steps = sideStep task steps
......
......@@ -38,6 +38,7 @@ project :: ((TaskValue a) r -> Maybe w) (ReadWriteShared r w) !(Task a) -> Task
* Once the transition to the continuation has been made it cannot be reversed.
*
* @param Task: The first step in the sequence
* @param Value before step function: Computes the value of the composition before a step is taken
* @param Continuations: A set of continuation definitions from which one is selected
* -OnValue: inspect the value, step if the predicate matches
* -OnAction: enable an action if the predicate matches, step if the actions is chosen
......@@ -46,7 +47,7 @@ project :: ((TaskValue a) r -> Maybe w) (ReadWriteShared r w) !(Task a) -> Task
*
* @return The combined task
*/
step :: !(Task a) [TaskStep a b] -> Task b | iTask a & iTask b
step :: !(Task a) ((Maybe a) -> (Maybe b)) [TaskStep a b] -> Task b | iTask a & iTask b
:: TaskStep a b
= OnValue ((TaskValue a) -> Maybe (Task b))
......
......@@ -65,8 +65,8 @@ where
Nothing = (result, iworld)
Error e = (exception e, iworld)
step :: !(Task a) [TaskStep a b] -> Task b | iTask a & iTask b
step (Task evala) conts = Task eval
step :: !(Task a) ((Maybe a) -> (Maybe b)) [TaskStep a b] -> Task b | iTask a & iTask b
step (Task evala) lhsValFun conts = Task eval
where
eval event repOpts (TCInit taskId ts) iworld
# (taskIda,iworld) = getNextTaskId iworld
......@@ -86,7 +86,8 @@ where
ValueResult val info rep ntreea = case searchContValue val mbcommit conts of
Nothing
# info = {TaskInfo|info & lastEvent = max ts info.TaskInfo.lastEvent}
= Left (ValueResult NoValue info (doStepLayout taskId repOpts rep val) (TCStep taskId info.TaskInfo.lastEvent (Left ntreea)) )
# value = maybe NoValue (\v -> Value v False) (lhsValFun (case val of Value v _ = Just v; _ = Nothing))
= Left (ValueResult value info (doStepLayout taskId repOpts rep val) (TCStep taskId info.TaskInfo.lastEvent (Left ntreea)) )
Just rewrite = Right (rewrite,Just ntreea, info.TaskInfo.lastEvent)
ExceptionResult e str = case searchContException e str conts of
Nothing = Left (ExceptionResult e str)
......
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