diff options
author | Eduardo Julian | 2019-02-19 22:52:52 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-02-19 22:52:52 -0400 |
commit | 2b105c8694b87a63bd151cd0966c9d5dcfaae672 (patch) | |
tree | 6264e1fceee61337b631ac0569c23d24a5f89149 /stdlib/source/lux/tool/compiler/phase/translation/js/loop.lux | |
parent | 8892e902809e680a067da9c85d54cae2acc82ce8 (diff) |
Moved looping machinery over.
Diffstat (limited to 'stdlib/source/lux/tool/compiler/phase/translation/js/loop.lux')
-rw-r--r-- | stdlib/source/lux/tool/compiler/phase/translation/js/loop.lux | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/stdlib/source/lux/tool/compiler/phase/translation/js/loop.lux b/stdlib/source/lux/tool/compiler/phase/translation/js/loop.lux new file mode 100644 index 000000000..8d0cefe4e --- /dev/null +++ b/stdlib/source/lux/tool/compiler/phase/translation/js/loop.lux @@ -0,0 +1,41 @@ +(.module: + [lux (#- Scope) + [control + ["." monad (#+ do)]] + [data + ["." product] + ["." text + format] + [collection + ["." list ("#/." functor)]]] + [host + ["_" js (#+ Computation Var)]]] + [// + [runtime (#+ Operation Phase)] + ["." reference] + ["//." case] + ["/." // + ["//." // + [synthesis (#+ Scope Synthesis)]]]]) + +(def: @scope (_.var "scope")) + +(def: #export (scope translate [start initsS+ bodyS]) + (-> Phase (Scope Synthesis) (Operation Computation)) + (do ////.monad + [initsO+ (monad.map @ translate initsS+) + bodyO (///.with-anchor @scope + (translate bodyS)) + #let [closure (_.function @scope + (|> initsS+ + list.enumerate + (list/map (|>> product.left (n/+ start) //case.register))) + (_.return bodyO))]] + (wrap (_.apply/* closure initsO+)))) + +(def: #export (recur translate argsS+) + (-> Phase (List Synthesis) (Operation Computation)) + (do ////.monad + [@scope ///.anchor + argsO+ (monad.map @ translate argsS+)] + (wrap (_.apply/* @scope argsO+)))) |