aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/tool/compiler/phase/generation/scheme/structure.jvm.lux
blob: c586f0706a0dbac855308352365d1c62895ef761 (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
(.module:
  [lux #*
   [control
    ["." monad (#+ do)]]
   [host
    ["_" scheme (#+ Expression)]]]
  [//
   ["." runtime (#+ Operation Phase)]
   ["." primitive]
   ["." ///
    [analysis (#+ Variant Tuple)]
    ["." synthesis (#+ Synthesis)]]])

(def: #export (tuple generate elemsS+)
  (-> Phase (Tuple Synthesis) (Operation Expression))
  (case elemsS+
    #.Nil
    (:: ///.monad wrap (primitive.text synthesis.unit))

    (#.Cons singletonS #.Nil)
    (generate singletonS)

    _
    (do ///.monad
      [elemsT+ (monad.map @ generate elemsS+)]
      (wrap (_.vector/* elemsT+)))))

(def: #export (variant generate [lefts right? valueS])
  (-> Phase (Variant Synthesis) (Operation Expression))
  (do ///.monad
    [valueT (generate valueS)]
    (wrap (runtime.variant [lefts right? valueT]))))