aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/program.lux
blob: b1619e830dec1ccc1d5245dfcba1844f0a75e470 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
(;module:
  lux
  (lux (control monad)
       [io #- run]
       [cli #+ program: CLI Monad<CLI>])
  (luxc ["&;" parser]))

(type: Path Text)

(type: Platform
  #JVM
  #JS)

(type: Mode
  #Release
  #Debug)

(type: Compilation
  {#mode Mode
   #platform Platform
   #program Path
   #target Path})

(type: Inputs
  {#resources (List Path)
   #sources (List 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: mode^
  (CLI Mode)
  ($_ cli;alt
      (marker (list "release"))
      (marker (list "debug"))))

(def: platform^
  (CLI Platform)
  ($_ cli;alt
      (marker (list "jvm"))
      (marker (list "js"))))

(def: compilation^
  (CLI Compilation)
  ($_ cli;seq
      mode^
      platform^
      (tagged (list "-p" "--program"))
      (tagged (list "-t" "--target"))))

(def: inputs^
  (CLI Inputs)
  ($_ cli;seq
      (cli;some (tagged (list "-r" "--resource")))
      (cli;some (tagged (list "-s" "--source")))))

(program: ([[command [resources sources]]
            (cli;seq (cli;opt compilation^)
                     inputs^)])
  (case command
    #;None
    (io (log! "Hello, REPL!"))

    (#;Some [mode platform program target])
    (io (log! "Hello, compilation!"))))