(.module: [lux (#- Scope) [abstract ["." monad (#+ do)]] [data ["." product] ["." text] [number ["n" nat]] [collection ["." list ("#@." functor)]]] [target ["_" js (#+ Computation Var)]]] ["." // #_ [runtime (#+ Operation Phase)] ["#." 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)) #let [closure (_.function @scope (|> initsS+ list.enumerate (list@map (|>> product.left (n.+ start) //case.register))) (_.return bodyO))]] (wrap (_.apply/* closure initsO+)))) (def: #export (recur generate argsS+) (-> Phase (List Synthesis) (Operation Computation)) (do ////.monad [@scope ///.anchor argsO+ (monad.map @ generate argsS+)] (wrap (_.apply/* @scope argsO+))))