Commit a358a992 authored by Mart Lubbers's avatar Mart Lubbers

base all accWorld variants on one base task

parent d5668ee2
Pipeline #27187 passed with stage
in 5 minutes and 10 seconds
......@@ -44,7 +44,7 @@ throw :: !e -> Task a | iTask a & iTask, toString e
*
* @gin False
*/
appWorld :: !(*World -> *World) -> Task () //TODO (All of these versions should be one core)
appWorld :: !(*World -> *World) -> Task ()
/**
* Evaluate a "World" function that also returns a value once.
......
......@@ -11,9 +11,9 @@ import iTasks.Internal.IWorld
import qualified iTasks.Internal.SDS as SDS
import qualified iTasks.Internal.AsyncSDS as ASDS
import Data.Error, Data.Maybe, Data.Func, Data.Either
import Data.Error, Data.Maybe, Data.Func, Data.Either, Data.Tuple
import Text.GenJSON
import StdString, StdBool, StdInt, StdMisc
import StdString, StdBool, StdInt, StdMisc, StdFunc
import qualified Data.Set as DS
import qualified Data.Map as DM
......@@ -27,17 +27,10 @@ throw :: !e -> Task a | iTask a & iTask, toString e
throw e = mkInstantTask (\taskId iworld -> (Error (dynamic e,toString e), iworld))
appWorld :: !(*World -> *World) -> Task ()
appWorld fun = mkInstantTask eval
where
eval taskId iworld=:{IWorld|world}
= (Ok (), {IWorld|iworld & world = fun world})
appWorld fun = accWorld $ tuple () o fun
accWorld :: !(*World -> *(!a,!*World)) -> Task a | iTask a
accWorld fun = mkInstantTask eval
where
eval taskId iworld=:{IWorld|world}
# (res,world) = fun world
= (Ok res, {IWorld|iworld & world = world})
accWorld fun = accWorldError (appFst Ok o fun) \_->""
accWorldError :: !(*World -> (!MaybeError e a, !*World)) !(e -> err) -> Task a | iTask a & TC, toString err
accWorldError fun errf = mkInstantTask eval
......
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