blob: a0a5d74eb2909037597f6aad58c208937661d885 (
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
|
(.module:
[lux (#- Scope)
[abstract
["." monad (#+ do)]]
[data
["." product]
["." text]
[collection
["." list ("#;." functor)]]]
[target
["_" scheme (#+ 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))]
(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+))))
|