blob: 101c49b95f316683747b296a0aef4a20b32dc982 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
(.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+))))
|