blob: e660b4158e6f31a35c0ee9d8767447c7cdffc559 (
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
|
(;module:
lux
(lux (control monad
["p" parser])
(concurrency ["P" promise]
["T" task])
(data ["e" error]
text/format)
[io #- run]
[cli #+ program: CLI])
(luxc ["&;" generator]))
## (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_proc ["io" "exit"] [1]))
(#e;Success output)
(wrap output))))
|