Commit 859370fa authored by Mart Lubbers's avatar Mart Lubbers

Print a warning on stderr in step with duplicate actions

parent a3dafe05
......@@ -14,9 +14,12 @@ import iTasks.Internal.Tonic.Shares
import iTasks.Internal.Client.Override
from iTasks.SDS.Combinators.Common import sdsFocus, sdsSplit, sdsTranslate, toReadOnly, mapRead, mapReadWriteError, mapSingle
from iTasks.WF.Combinators.Common import ifStable
from iTasks.Internal.SDS import write, read, readRegister, modify
import iTasks.WF.Tasks.System
import StdList, StdBool, StdTuple
from StdFunc import o
import qualified Data.Map as DM
import qualified Data.Queue as DQ
......@@ -76,8 +79,23 @@ where
(ExceptionResult e, iworld) = (ExceptionResult e, iworld)
(DestroyedResult, iworld) = (DestroyedResult, iworld)
removeDupBy :: (a a -> Bool) [a] -> [a]
removeDupBy eq [x:xs] = [x:removeDupBy eq (filter (not o eq x) xs)]
removeDupBy _ [] = []
step :: !(Task a) ((Maybe a) -> (Maybe b)) [TaskCont a (Task b)] -> Task b | TC a & JSONDecode{|*|} a & JSONEncode{|*|} a
step (Task evala) lhsValFun conts = Task eval
step task fun c
= if (length conts <> length c)
(step` (traceValue "Duplicate actions in step") (\_->Nothing) [OnValue (ifStable \_->step` task fun conts)])
(step` task fun conts)
conts = removeDupBy actionEq c
actionEq (OnAction (Action a) _) (OnAction (Action b) _) = a == b
actionEq _ _ = False
step` :: !(Task a) ((Maybe a) -> (Maybe b)) [TaskCont a (Task b)] -> Task b | TC a & JSONDecode{|*|} a & JSONEncode{|*|} a
step` (Task evala) lhsValFun conts = Task eval
eval event evalOpts (TCInit taskId ts) iworld
# (taskIda,iworld) = getNextTaskId iworld
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