aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/test/test/luxc/synthesizer/common.lux
blob: a74c64402d2fa85035c9bfeea2744e5af82ff9f2 (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
(;module:
  lux
  (lux (data [bool "bool/" Eq<Bool>]
             [text "text/" Eq<Text>])
       (meta [code])
       ["r" math/random "r/" Monad<Random>])
  (luxc (lang ["la" analysis]
              ["ls" synthesis])))

(def: #export gen-primitive
  (r;Random la;Analysis)
  (r;either (r;either (r;either (r/wrap (' []))
                                (r/map code;bool r;bool))
                      (r;either (r/map code;nat r;nat)
                                (r/map code;int r;int)))
            (r;either (r;either (r/map code;deg r;deg)
                                (r/map code;frac r;frac))
                      (r/map code;text (r;text +5)))))

(def: #export (corresponds? analysis synthesis)
  (-> la;Analysis ls;Synthesis Bool)
  (case [analysis synthesis]
    (^ [(^code []) (^code [])])
    true
    
    (^template [<tag> <test>]
      [[_ (<tag> valueA)] [_ (<tag> valueS)]]
      (<test> valueA valueS))
    ([#;Bool bool/=]
     [#;Nat  n.=]
     [#;Int  i.=]
     [#;Deg  d.=]
     [#;Frac f.=]
     [#;Text text/=])

    _
    false))