Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
clean-and-itasks
iTasks-SDK
Commits
d53d571c
Commit
d53d571c
authored
Aug 24, 2018
by
Bas Lijnse
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'transform-error' into 'master'
Modify transform so it can create an exception See merge request
!176
parents
f1adf579
f6040c46
Pipeline
#13510
passed with stage
in 9 minutes and 16 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
6 deletions
+21
-6
Libraries/iTasks/WF/Combinators/Core.dcl
Libraries/iTasks/WF/Combinators/Core.dcl
+16
-2
Libraries/iTasks/WF/Combinators/Core.icl
Libraries/iTasks/WF/Combinators/Core.icl
+5
-4
No files found.
Libraries/iTasks/WF/Combinators/Core.dcl
View file @
d53d571c
...
...
@@ -4,6 +4,7 @@ definition module iTasks.WF.Combinators.Core
*/
import
iTasks
.
WF
.
Definition
from
iTasks
.
SDS
.
Definition
import
::
SDS
from
Data
.
Error
import
::
MaybeError
(
Ok
)
from
Data
.
Maybe
import
::
Maybe
//* Next task actions
...
...
@@ -78,16 +79,29 @@ ActionClose :== Action "Close"
derive
class
iTask
AttachException
instance
toString
AttachException
/**
* Adds a result transformation function to a task.
* The resulting task is still considered a single step in the workflow.
*
* @param Function: The transformation function.
* @param Task: The task to which the transformation function is added
*
* @return The transformed task
*/
transformError
::
((
TaskValue
a
)
->
MaybeError
TaskException
(
TaskValue
b
))
!(
Task
a
)
->
Task
b
/**
* Adds a result transformation function to a task.
* The resulting task is still considered a single step in the workflow.
*
* @param Function: The transformation function.
It works on maybe's to also map over instable tasks.
* @param Function: The transformation function.
* @param Task: The task to which the transformation function is added
*
* @return The transformed task
* @type ((TaskValue a) -> TaskValue b) !(Task a) -> Task b
*/
transform
::
((
TaskValue
a
)
->
TaskValue
b
)
!(
Task
a
)
->
Task
b
transform
f
:==
transformError
(\
tv
->
Ok
(
f
tv
))
/**
* The generic sequential combinator.
...
...
Libraries/iTasks/WF/Combinators/Core.icl
View file @
d53d571c
...
...
@@ -72,12 +72,13 @@ where
derive
class
iTask
AttachException
transform
::
((
TaskValue
a
)
->
TaskValue
b
)
!(
Task
a
)
->
Task
b
transform
f
(
Task
evala
)
=
Task
eval
transform
Error
::
((
TaskValue
a
)
->
MaybeError
TaskException
(
TaskValue
b
)
)
!(
Task
a
)
->
Task
b
transform
Error
f
(
Task
evala
)
=
Task
eval
where
eval
event
evalOpts
tree
iworld
=
case
evala
event
evalOpts
tree
iworld
of
//TODO: guarantee stability
(
ValueResult
val
lastEvent
rep
tree
,
iworld
)
=
(
ValueResult
(
f
val
)
lastEvent
rep
tree
,
iworld
)
(
ValueResult
val
lastEvent
rep
tree
,
iworld
)
=
case
f
val
of
Error
e
=
(
ExceptionResult
e
,
iworld
)
Ok
v
=
(
ValueResult
v
lastEvent
rep
tree
,
iworld
)
(
ExceptionResult
e
,
iworld
)
=
(
ExceptionResult
e
,
iworld
)
(
DestroyedResult
,
iworld
)
=
(
DestroyedResult
,
iworld
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment