aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/lang/translation/ruby/primitive.jvm.lux
blob: cc5e5752e1bd9a9ae952a72cfd10e0bde2162d5a (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 (control pipe)
       (data [number]
             text/format)
       [macro "meta/" Monad<Meta>])
  (luxc (lang (host [ruby #+ Ruby Expression Statement]))))

(def: #export translate-bit
  (-> Bit (Meta Expression))
  (|>> ruby.bool meta/wrap))

(def: #export translate-int
  (-> Int (Meta Expression))
  (|>> ruby.int meta/wrap))

(def: #export translate-frac
  (-> Frac (Meta Expression))
  (|>> (cond> [(f/= number.positive-infinity)]
              [(new> "(1.0/0.0)")]
              
              [(f/= number.negative-infinity)]
              [(new> "(-1.0/0.0)")]
              
              [(f/= number.not-a-number)]
              [(new> "(0.0/0.0)")]
              
              ## else
              [%f])
       meta/wrap))

(def: #export translate-text
  (-> Text (Meta Expression))
  (|>> %t meta/wrap))