aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/test/test/luxc/synthesizer/common.lux
blob: 88eeaea7c0a79e82054d362afb001a6a2776aa79 (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
(;module:
  lux
  (lux (data [bool "B/" Eq<Bool>]
             [text "T/" Eq<Text>])
       ["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 #la;Unit)
                                (r/map (|>. #la;Bool) r;bool))
                      (r;either (r/map (|>. #la;Nat) r;nat)
                                (r/map (|>. #la;Int) r;int)))
            (r;either (r;either (r/map (|>. #la;Deg) r;deg)
                                (r/map (|>. #la;Real) r;real))
                      (r/map (|>. #la;Text) (r;text +5)))))

(def: #export (corresponds? analysis synthesis)
  (-> la;Analysis ls;Synthesis Bool)
  (case [analysis synthesis]
    (^template [<analysis> <synthesis> <test>]
      [(<analysis> valueA) (<synthesis> valueS)]
      (<test> valueA valueS))
    ([#la;Unit #ls;Unit is]
     [#la;Bool #ls;Bool B/=]
     [#la;Nat  #ls;Nat  n.=]
     [#la;Int  #ls;Int  i.=]
     [#la;Deg  #ls;Deg  d.=]
     [#la;Real #ls;Real r.=]
     [#la;Text #ls;Text T/=])

    _
    false))