step as parallel
authorMart Lubbers <mart@martlubbers.net>
Mon, 19 Aug 2019 17:52:08 +0000 (19:52 +0200)
committerMart Lubbers <mart@martlubbers.net>
Mon, 19 Aug 2019 17:52:08 +0000 (19:52 +0200)
stepparallel/test.icl

index b5253ef..0004118 100644 (file)
@@ -5,6 +5,7 @@ import iTasks
 import Data.Either
 import StdEnv
 import Data.Func
+import Data.Functor
 
 Start w = flip doTasks w $
        updateInformation () [] 42
@@ -35,25 +36,25 @@ where
                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)
+       stepCont (OnException f) = OnException \e->add (f e)
+       stepCont (OnAllExceptions f) = OnAllExceptions \e->add (f e)
        
        transform f v
                # v = case v of
                        Value [(_, v)] _ = case v of
                                NoValue = NoValue
                                Value (Left (Just v)) s = Value v s
-                               Value _ = NoValue
+                               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)
+               = add <$> f v
+       
+       add t = (Embedded, \stl->
+               get (sdsFocus {onlyIndex=Nothing,onlyTaskId=Nothing,onlySelf=False,includeValue=False,includeProgress=False,includeAttributes=False} stl)
+               >>- \(_, pts)->case pts of
+                       [tli:_] = removeTask tli.TaskListItem.taskId stl
+                               >-| t @ Right
+                       _ = abort "shouldn't happen"
+               )
 
-//     stepCont (OnException f) = OnException \e->(Embedded, \stl->e f @ Right)
-//     stepCont (OnAllExceptions b) = OnAllExceptions b