+++ /dev/null
-module test
-
-import StdMisc
-import iTasks
-import Data.Either
-import StdEnv
-import Data.Func
-
-Start w = flip doTasks w $
- updateInformation () [] 42
- >>* [OnAction (Action "Continue") (always (return 43))]
-
-(>>*) infixl 1// :: !(Task a) ![TaskCont a (Task b)] -> Task b | iTask a & iTask b
-(>>*) task steps :== step task (const Nothing) steps
-
-step :: !(Task a) ((Maybe a) -> Maybe b) [TaskCont a (Task b)] -> Task b | iTask a & iTask b
-step lhs lhsValFun conts
- = parallel
- [(Embedded, \stl->lhs @? \v->case v of
- NoValue = Value (Left Nothing) False
- (Value v s) = Value (Left (Just v)) s
- )]
- (map stepCont conts)
- @? stepVal lhsValFun
-where
- stepVal :: ((Maybe a) -> Maybe b) (TaskValue [(Int, TaskValue (Either (Maybe a) b))]) -> TaskValue b
- stepVal tfun NoValue = NoValue
- stepVal tfun (Value [(_, x):_] _) = case x of
- //Not yet stepped:
- Value (Left l) s = case tfun l of
- Nothing = NoValue
- Just v = Value v False
- //Stepped but no value
- NoValue = NoValue
- Value (Right r) s = Value r s
- stepVal _ _ = abort "cannot happen"
-
- stepCont :: (TaskCont a (Task b)) -> TaskCont
- [(Int, TaskValue (Either (Maybe a) b))]
- (ParallelTaskType, ParallelTask (Either (Maybe a) b))
- stepCont (OnValue f) = OnValue (transform f)
- stepCont (OnAction a f) = OnAction a (transform f)
-
- transform f v
- # v = case v of
- Value [(_, v)] _ = case v of
- NoValue = NoValue
- Value (Left (Just v)) s = Value v s
- Value _ = NoValue
- NoValue = NoValue
- = case f v of
- Nothing = Nothing
- Just t = Just (Embedded, \stl->
- get (sdsFocus {onlyIndex=Nothing,onlyTaskId=Nothing,onlySelf=False,includeValue=False,includeProgress=False,includeAttributes=False} stl)
- removeTask taskId stl
- >-| t @ Right)
-
-// stepCont (OnException f) = OnException \e->(Embedded, \stl->e f @ Right)
-// stepCont (OnAllExceptions b) = OnAllExceptions b