aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/js/structure.lux
blob: 64680da6df33fdf9ccf1fee3172152a4bfd165fd (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
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

(.require
 [library
  [lux (.except Variant Tuple Synthesis)
   [abstract
    ["[0]" monad (.only do)]]
   [meta
    [compiler
     [target
      ["_" js (.only Expression)]]]]]]
 ["[0]" //
  ["[1][0]" runtime (.only Operation Phase Translator)]
  ["[1][0]" primitive]
  ["///[1]" ////
   ["[0]" phase (.use "[1]#[0]" monad)]
   ["[1][0]" synthesis (.only Synthesis)]
   [analysis
    [complex (.only Variant Tuple)]]]])

(def .public (tuple translate archive elemsS+)
  (Translator (Tuple Synthesis))
  (when elemsS+
    {.#End}
    (phase#in //runtime.unit)

    {.#Item singletonS {.#End}}
    (translate archive singletonS)

    _
    (do [! phase.monad]
      [elemsT+ (monad.each ! (translate archive) elemsS+)]
      (in (_.array elemsT+)))))

(def .public (variant translate archive [lefts right? valueS])
  (Translator (Variant Synthesis))
  (phase#each (//runtime.variant (_.i32 (.int lefts))
                                 (//runtime.flag right?))
              (translate archive valueS)))