Core.dcl 2.97 KB
Newer Older
1
definition module iTasks.WF.Tasks.Core
2
/**
Haye Böhm's avatar
Haye Böhm committed
3
* This module provis the builtin basic tasks
4
*/
5
import iTasks.WF.Definition
6 7
import iTasks.SDS.Definition

8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
from Data.Error import :: MaybeError
from System.OSError import :: MaybeOSError, :: OSError, :: OSErrorCode, :: OSErrorMessage
from iTasks.UI.Editor import :: EditMode

/**
* Lifts a value to the task domain. The task finishes immediately and yields its parameter
* as result of the task.
*
* @param Value: The value to be returned
*				@default ()
* @return A task that will return the value defined by the parameter
*/
treturn :: !a -> Task a | iTask a

/**
* Exception throwing. This will throw an exception of arbitrary type e which has to be caught
* by a higher level exception handler combinator.
*
* @param Value: The exception value
* @return The combined task
*/
throw :: !e -> Task a | iTask a & iTask, toString e

/**
* Evaluate a "World" function that does not yield any result once.
*
* @param World function: The function to evaluate
* @return A () task that evaluates the function
*/
37
appWorld :: !(*World -> *World)			-> Task ()
38 39 40 41 42 43 44

/**
* Evaluate a "World" function that also returns a value once.
*
* @param World function: The function to evaluate
* @return A task that evaluates the function and yield a
*/
45
accWorld :: !(*World -> *(a,*World))	-> Task a | iTask a
46 47 48 49 50 51 52 53 54

/**
* Evaluate a "World" function that also returns a MaybeError value.
* If the MaybeError value is Error, the error is transformed.
* @param World function: The function to evaluate
* @param Error function: Error transformation function
*
* @return A  task that evaluates the function
*/
55
accWorldError   :: !(*World -> (MaybeError e a, *World)) !(e -> err) -> Task a | iTask a & TC, toString err
56 57 58 59 60 61 62 63 64

/**
* Evaluate a "World" function that also returns a MaybeOSError value.
* If the MaybeError value is Error, the error is transformed.
* @param World function: The function to evaluate
* @param Error function: Error transformation function
*
* @return A task that evaluates the function
*/
65
accWorldOSError :: !(*World -> (MaybeOSError a, *World))             -> Task a | iTask a
66

67 68
:: OSException			= OSException !OSError
instance toString OSException
69

70 71
/**
* Core interaction task. All other interaction tasks are derived from this one.
72 73 74
* There are two almost identical versions:
* The `interactRW` version can update the given sds.
* The `interactR` version only reads, which means it can also be used for sds's that are not writable.
75
*/
76
:: InteractionHandlers l r w v =
77 78 79
    { onInit    :: !(r -> (l, EditMode v))
    , onEdit    :: !(v l (Maybe v) -> (l, v, Maybe (r -> w)))
    , onRefresh :: !(r l (Maybe v) -> (l, v, Maybe (r -> w)))
80
	}
81

82
//Version which can write shared data
83
interactRW :: !(sds () r w) (InteractionHandlers l r w v) (Editor v) -> Task (l,v) | iTask l & iTask r & iTask v & TC r & TC w & RWShared sds
84
//Version which does not write shared data
85
interactR :: (sds () r w) (InteractionHandlers l r w v) (Editor v) -> Task (l,v) | iTask l & iTask r & iTask v & TC r & TC w & Registrable sds