blob: 761a6eabc36f601df7f3caefb6c021251e464b74 (
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
(;module:
lux
(lux (control monad
["p" parser])
(concurrency ["P" promise]
["T" task])
(data ["e" error]
text/format)
[io #- run]
[cli #+ program: CLI])
(luxc (lang [";L" translation])))
## (type: Compilation
## {#program &;Path
## #target &;Path})
## (def: (marker tokens)
## (-> (List Text) (CLI Unit))
## (cli;after (cli;option tokens)
## (:: Monad<CLI> wrap [])))
## (def: (tagged tags)
## (-> (List Text) (CLI Text))
## (cli;after (cli;option tags)
## cli;any))
## (def: compilation^
## (CLI Compilation)
## ($_ cli;seq
## (tagged (list "-p" "--program"))
## (tagged (list "-t" "--target"))))
## (program: ([command (cli;opt compilation^)]
## [sources (cli;some (tagged (list "-s" "--source")))])
## (case command
## #;None
## (io (log! "No REPL for you!"))
## (#;Some [program target])
## (exec (&compiler;compile-program program target sources)
## (io []))))
(def: (or-crash! action)
(All [a] (-> (T;Task a) (P;Promise a)))
(do P;Monad<Promise>
[?output action]
(case ?output
(#e;Error error)
(exec (log! (format "\n"
"Compilation failed:" "\n"
error "\n"))
("lux io exit" 1))
(#e;Success output)
(wrap output))))
|