Repository navigation
Open
Labels
Description
There are essentially 3 variations for normal dataflow, AKA dataflow-flatmap:
~~>
~/~>
~~> +~/~>
IMO these should be implemented separately, using do-then, do-else, do-then-else:
def _dataflow_then(s: Script[Any], t: Any => Script[Any], e: Throwable => Script[Any]): Script[Any] = {
var s_node: N_call[Any] = null
([do @{s_node = there.asInstanceOf[N_call[Any]]}: s then t(s_node.$success)^])
}
def _dataflow_else(s: Script[Any], t: Any => Script[Any], e: Throwable => Script[Any]): Script[Any] = {
var s_node: N_call[Any] = null
([do @{s_node = there.asInstanceOf[N_call[Any]]}: s else e(s_node.$failure)^])
}
def _dataflow_then_else(s: Script[Any], t: Any => Script[Any], e: Throwable => Script[Any]): Script[Any] = {
var s_node: N_call[Any] = null
([do @{s_node = there.asInstanceOf[N_call[Any]]}: s then t(s_node.$success)^
else e(s_node.$failure)^])
}
Something similar holds for dataflow-map:
def _dataflow_then_map(s: Script[Any], f: T => Any): Script[Any] = {
var s_node: N_call[Any] = null
([do @{s_node = there.asInstanceOf[N_call[Any]]}: s then ^let f(s_node.$success) ])
}
def _dataflow_else_map(s: Script[Any], g: Throwable => Any): Script[Any] = {
var s_node: N_call[Any] = null
([do @{s_node = there.asInstanceOf[N_call[Any]]}: s else ^let g(s_node.$failure) ])
}
def _dataflow_then_else_map(s: Script[Any], f: T => Any, g: Throwable => Any): Script[Any] = {
var s_node: N_call[Any] = null
([do @{s_node = there.asInstanceOf[N_call[Any]]}: s then ^let f(s_node.$success)
else ^let g(s_node.$failure) ])
}
Probably the latter three may be implemented more efficiently using dedicated do-thenMap, do-elseMap, do-thenMap-elseMap nodes.
Also the parser should start to accept syntax for the else-parts.
Activity
AndreVanDelft commentedon May 24, 2016
Another thing: to pass the earlier mentioned Pastiche test, there should also be a dataflow operator that transfers both the success data and the failure exception, packed in the
Try:This requires another new construct:
which is in ACP terms equivalent to
The difference in Scala terms is that there is only one occurrence of
y.