aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux
blob: 2a69cfb0827ae87ea3e9bdbd153fb0d2bf869c76 (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
(.module:
  [library
   [lux #*
    [abstract
     ["." monad (#+ do)]]
    [data
     [collection
      ["." list]]]
    [target
     ["_" r (#+ Expression)]]]]
  ["." // #_
   ["#." runtime (#+ Operation Phase Generator)]
   ["#." primitive]
   ["///#" //// #_
    [analysis (#+ Variant Tuple)]
    ["#." synthesis (#+ Synthesis)]
    ["//#" /// #_
     ["#." phase ("#\." monad)]]]])

(def: .public (tuple expression archive elemsS+)
  (Generator (Tuple Synthesis))
  (case elemsS+
    #.End
    (///////phase\in (//primitive.text /////synthesis.unit))

    (#.Item singletonS #.End)
    (expression archive singletonS)

    _
    (|> elemsS+
        (monad.each ///////phase.monad (expression archive))
        (///////phase\each _.list))))

(def: .public (variant expression archive [lefts right? valueS])
  (Generator (Variant Synthesis))
  (let [tag (if right?
              (++ lefts)
              lefts)]
    (///////phase\each (|>> (//runtime.variant tag right?))
                       (expression archive valueS))))