Project

Profile

Help

Bug #2321 » taskBug.xsl

Debbie Lockett, 2019-01-16 13:09

 
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:map="http://www.w3.org/2005/xpath-functions/map"
xmlns:array="http://www.w3.org/2005/xpath-functions/array"
xmlns:io="http://io"
xmlns:task="http://task"
exclude-result-prefixes="#all"
version="3.0">
<!-- 9.9.0.2 bug -->
<xsl:variable name="realworldEl" as="element(io:realworld)">
<io:realworld/>
</xsl:variable>
<xsl:function name="task:create-monadic-task" as="map(*)">
<xsl:param name="apply-fn" as="function(element(io:realworld)) as item()+"/>
<xsl:sequence select="map {
'apply': $apply-fn,
'bind' : function($binder as function(item()*) as map(*)) as map(*) {
let $bound-apply-fn := function($realworld) {
let $io-res := $apply-fn($realworld)
return
$binder(fn:tail($io-res))('apply')(fn:head($io-res))
}
return
task:create-monadic-task($bound-apply-fn)
}
}"/>
</xsl:function>
<xsl:function name="task:RUN-UNSAFE">
<xsl:param name="task" as="map(*)"/>
<xsl:sequence select="subsequence(
$task?apply($realworldEl),
2
)"/>
</xsl:function>
<xsl:function name="task:test1">
<xsl:param name="realworld" as="element(io:realworld)"/>
<xsl:sequence select="($realworld, 1234)"/>
</xsl:function>
<!-- Example 1: Create a task from a pure value and run it -->
<xsl:template name="ex1">
<xsl:sequence select="task:RUN-UNSAFE(
task:create-monadic-task(function($realworld) {
($realworld, 1234)
})
)"/>
</xsl:template>

</xsl:stylesheet>
(1-1/2)