diff options
Diffstat (limited to 'stdlib/source/lux/tool/compiler/phase/generation/scheme/loop.jvm.lux')
-rw-r--r-- | stdlib/source/lux/tool/compiler/phase/generation/scheme/loop.jvm.lux | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/stdlib/source/lux/tool/compiler/phase/generation/scheme/loop.jvm.lux b/stdlib/source/lux/tool/compiler/phase/generation/scheme/loop.jvm.lux new file mode 100644 index 000000000..0e4adcf03 --- /dev/null +++ b/stdlib/source/lux/tool/compiler/phase/generation/scheme/loop.jvm.lux @@ -0,0 +1,41 @@ +(.module: + [lux (#- Scope) + [control + ["." monad (#+ do)]] + [data + ["." product] + ["." text + format] + [collection + ["." list ("#/." functor)]]] + [host + ["_" scheme (#+ Computation Var)]]] + [// + [runtime (#+ Operation Phase)] + ["." reference] + ["//." case] + ["/." // + ["//." // + [synthesis (#+ Scope Synthesis)]]]]) + +(def: @scope (_.var "scope")) + +(def: #export (scope generate [start initsS+ bodyS]) + (-> Phase (Scope Synthesis) (Operation Computation)) + (do ////.monad + [initsO+ (monad.map @ generate initsS+) + bodyO (///.with-anchor @scope + (generate bodyS))] + (wrap (_.letrec (list [@scope (_.lambda [(|> initsS+ + list.enumerate + (list/map (|>> product.left (n/+ start) //case.register))) + #.None] + bodyO)]) + (_.apply/* @scope initsO+))))) + +(def: #export (recur generate argsS+) + (-> Phase (List Synthesis) (Operation Computation)) + (do ////.monad + [@scope ///.anchor + argsO+ (monad.map @ generate argsS+)] + (wrap (_.apply/* @scope argsO+)))) |