aboutsummaryrefslogtreecommitdiff
path: root/src/runtime.ts
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/runtime.ts23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/runtime.ts b/src/runtime.ts
index f2fc516..91393be 100644
--- a/src/runtime.ts
+++ b/src/runtime.ts
@@ -150,11 +150,7 @@ const evaluateType = async (effTyp: Type, node: Node): Promise<string[]> => {
Seq: async () => {
const [effectTyps] = effTyp.getTypeArguments()
- const effectResults: string[] = []
- for (const item of effectTyps?.getTupleElements() ?? []) {
- effectResults.push(...(await evaluateType(item, node)))
- }
-
+ const effectResults = await evalList(effectTyps?.getTupleElements() ?? [], node)
const hash = uuid()
addResult(hash, `[
${effectResults.map(r => `${RESULT_TYPE_NAME}[${JSON.stringify(r)}]`).join(', ')}
@@ -162,6 +158,15 @@ const evaluateType = async (effTyp: Type, node: Node): Promise<string[]> => {
return [hash]
},
+ Then: async () => {
+ const [effectTyps] = effTyp.getTypeArguments()
+ const effectResults = await evalList(effectTyps?.getTupleElements() ?? [], node)
+ const resultKey = effectResults[effectResults.length - 1]
+ const hash = uuid()
+ addResult(hash, `${RESULT_TYPE_NAME}[${JSON.stringify(resultKey)}]['output']`)
+ return [hash]
+ },
+
_: async () => {
if (name && customEffects[name]) {
customEffects[name](...effTyp.getTypeArguments())
@@ -173,6 +178,14 @@ const evaluateType = async (effTyp: Type, node: Node): Promise<string[]> => {
})
}
+const evalList = async (effectTyps: Type[], node: Node) => {
+ const effectResults: string[] = []
+ for (const item of effectTyps ?? []) {
+ effectResults.push(...(await evaluateType(item, node)))
+ }
+ return effectResults
+}
+
const main = async () => {
if (typeRefNode) {
const resultType = entryPoint?.getType()