blob: 36e5678db402f6f214808e63e6fc06a34afe616b (
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
|
(.module:
[lux #*
[abstract
[monad (#+ do)]]
[control
["." try]]
[data
[text
["%" format (#+ format)]]]]
[///
["." phase
[macro (#+ Expander)]
[".P" analysis
["." type]]
[".P" synthesis]
["." generation]
[//
[analysis (#+ Operation)]
["." synthesis]]]])
(type: #export Eval
(-> Nat Type Code (Operation Any)))
(def: #export (evaluator expander synthesis-state generation-state generate)
(All [anchor expression statement]
(-> Expander
synthesis.State+
(generation.State+ anchor expression statement)
(generation.Phase anchor expression statement)
Eval))
(let [analyze (analysisP.phase expander)]
(function (eval count type exprC)
(do phase.monad
[exprA (type.with-type type
(analyze exprC))]
(phase.lift (do try.monad
[exprS (|> exprA synthesisP.phase (phase.run synthesis-state))]
(phase.run generation-state
(do phase.monad
[exprO (generate exprS)]
(generation.evaluate! (format "eval" (%.nat count)) exprO)))))))))
|