blob: 227a2eda94d6ade424bb40a8bf279877370e0bba (
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)
[control
[monad (#+ do)]]
[data
[product]
["." text
format]
[collection
[list ("list/" Functor<List>)]]]
[macro]]
[/////
[host ["_" scheme (#+ Computation Var)]]
["." compiler
[synthesis (#+ Scope Synthesis)]]]
[///]
[//runtime (#+ Operation Translator)]
[//reference])
(def: @scope (_.var "scope"))
(def: #export (scope translate [start initsS+ bodyS])
(-> Translator (Scope Synthesis) (Operation Computation))
(do compiler.Monad<Operation>
[initsO+ (monad.map @ translate initsS+)
bodyO (///.with-anchor @scope
(translate bodyS))]
(wrap (_.letrec (list [@scope (_.lambda [(|> initsS+
list.enumerate
(list/map (|>> product.left (n/+ start) //reference.local')))
#.None]
bodyO)])
(_.apply/* @scope initsO+)))))
(def: #export (recur translate argsS+)
(-> Translator (List Synthesis) (Operation Computation))
(do compiler.Monad<Operation>
[@scope ///.anchor
argsO+ (monad.map @ translate argsS+)]
(wrap (_.apply/* @scope argsO+))))
|