blob: a00fc2b12d4b2a3c4242d71001b1c3e6255871bb (
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]
[number
["n" nat]]
[text
["%" format (#+ format)]]
[collection
["." list ("#@." functor)]]]
[target
["_" common-lisp (#+ Expression)]]]
["." // #_
[runtime (#+ Operation Phase)]
["#." case]
["#/" //
["#/" //
[//
[synthesis (#+ Scope Synthesis)]]]]])
(def: #export (scope generate [start initsS+ bodyS])
(-> Phase (Scope Synthesis) (Operation (Expression Any)))
(do ////.monad
[@scope (:: @ map (|>> %.nat (format "scope") _.var) ///.next)
initsG+ (monad.map @ generate initsS+)
bodyG (///.with-anchor @scope
(generate bodyS))]
(wrap (_.labels (list [@scope {#_.input (|> initsS+
list.enumerate
(list@map (|>> product.left (n.+ start) //case.register))
_.args)
#_.output bodyG}])
(_.funcall/+ [(_.function/1 @scope) initsG+])))))
(def: #export (recur generate argsS+)
(-> Phase (List Synthesis) (Operation (Expression Any)))
(do ////.monad
[@scope ///.anchor
argsO+ (monad.map @ generate argsS+)]
(wrap (_.call/* @scope argsO+))))
|