TaskState.icl 2.16 KB
Newer Older
1
implementation module iTasks.Internal.TaskState
2

3
import Text.GenJSON, StdString
4
import iTasks.UI.Definition
5
import iTasks.WF.Definition
6
from iTasks.WF.Combinators.Core import :: AttachmentStatus
7

8 9 10 11
from iTasks.Internal.Task	import exception
from iTasks.Internal.TaskEval import :: TaskTime, :: TaskEvalInfo(..), :: TonicOpts(..)
from iTasks.Internal.Tonic.AbsSyn import :: ExprId (..)
import iTasks.Internal.Serialization
12
import Data.CircularStack
13
import Data.Error, Data.Either
14

15 16
derive JSONEncode TIMeta, TIValue, TIReduct, TaskTree, ParallelTaskState, ParallelTaskChange, TaskResult, TaskEvalInfo, TonicOpts, CircularStack
derive JSONDecode TIMeta, TIValue, TIReduct, TaskTree, ParallelTaskState, ParallelTaskChange, TaskResult, TaskEvalInfo, TonicOpts, CircularStack
Bas Lijnse's avatar
Bas Lijnse committed
17

18 19 20
JSONEncode{|DeferredJSON|} _ (DeferredJSON a)
	= JSONEncode{|*|} False a
JSONEncode{|DeferredJSON|} _ (DeferredJSONNode json)
21
	= [json]
Bas Lijnse's avatar
Bas Lijnse committed
22

23
JSONDecode{|DeferredJSON|} _ []
24
	= (Just (DeferredJSONNode JSONNull), [])
25
JSONDecode{|DeferredJSON|} _ [x:xs]
26
	= ((Just (DeferredJSONNode x)), xs)
27
JSONDecode{|DeferredJSON|} _ l
28
	= (Nothing, l)
29

30 31 32
taskIdFromTaskTree :: TaskTree -> MaybeError TaskException TaskId
taskIdFromTaskTree (TCInit                  taskId _)         = Ok taskId
taskIdFromTaskTree (TCBasic                 taskId _ _ _)     = Ok taskId
33
taskIdFromTaskTree (TCInteract              taskId _ _ _ _)   = Ok taskId
34 35
taskIdFromTaskTree (TCProject               taskId _ _)       = Ok taskId
taskIdFromTaskTree (TCStep                  taskId _ _)       = Ok taskId
36
taskIdFromTaskTree (TCParallel              taskId _ _ _)     = Ok taskId
37
taskIdFromTaskTree (TCShared                taskId _ _)       = Ok taskId
Bas Lijnse's avatar
Bas Lijnse committed
38
taskIdFromTaskTree (TCAttach                taskId _ _ _ _)   = Ok taskId
39 40
taskIdFromTaskTree (TCExposedShared         taskId _ _ _)     = Ok taskId
taskIdFromTaskTree (TCStable                taskId _ _)       = Ok taskId
41
taskIdFromTaskTree (TCLayout                _ tt)             = taskIdFromTaskTree tt
Bas Lijnse's avatar
Bas Lijnse committed
42
taskIdFromTaskTree (TCNop)                                    = Error (exception "Unable to obtain TaskId from TaskTree (TCNop)")
43
taskIdFromTaskTree (TCDestroy               tt)               = taskIdFromTaskTree tt
Bas Lijnse's avatar
Bas Lijnse committed
44