aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/specification/compositor.lux
blob: e6494e01194083821603f2a3237943b8f2c6707e (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
(.require
 [lux (.except)
  ["_" test (.only Test)]
  [abstract
   [monad (.only do)]]
  [control
   ["[0]" io (.only IO)]
   ["[0]" try]]
  [math
   ["r" random]]
  [tool
   [compiler
    ["[0]" analysis]
    ["[0]" declaration]
    [phase
     [macro (.only Expander)]
     [generation (.only Bundle)]]
    [default
     [platform (.only Platform)]]]]]
 ["[0]" /
  ["[1][0]" common (.only Runner Definer)]
  ["[1]./" analysis
   ["[1][0]" type]]
  ["[1]./" generation
   ["[1][0]" primitive]
   ["[1][0]" structure]
   ["[1][0]" reference]
   ["[1][0]" case]
   ["[1][0]" function]
   ["[1][0]" common]]])

(def (test runner definer state expander)
  (-> Runner Definer analysis.State+ Expander Test)
  (all _.and
       (/analysis/type.spec expander state)
       (/generation/primitive.spec runner)
       (/generation/structure.spec runner)
       (/generation/reference.spec runner definer)
       (/generation/case.spec runner)
       (/generation/function.spec runner)
       (/generation/common.spec runner)
       ))

(def .public (spec platform bundle expander program)
  (All (_ anchor expression declaration)
    (-> (IO (Platform IO anchor expression declaration))
        (Bundle anchor expression declaration)
        Expander
        (-> expression declaration)
        Test))
  (do r.monad
    [_ (in [])
     .let [?state,runner,definer (<| io.run!
                                     (do io.monad
                                       [platform platform])
                                     (/common.executors platform
                                                        bundle
                                                        expander
                                                        program))]]
    (case ?state,runner,definer
      {try.#Success [[declaration_bundle declaration_state] runner definer]}
      (..test runner definer
              (the [declaration.#analysis declaration.#state] declaration_state)
              expander)

      {try.#Failure error}
      (_.failure error))))