blob: d99eec0e95db77a4055f141f2ec713344d955a37 (
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
|
(.module:
[lux (#- int)
[control
[pipe (#+ cond> new>)]]
[data
[number
["." i64]
["." frac]]
[text
format]]
[host
["_" js (#+ Expression)]]]
[//
["//." runtime (#+ Operation)]
[//
["//." // ("#/." monad)]]])
(def: #export bit
(-> Bit (Operation Expression))
(|>> _.boolean /////wrap))
(def: high
(-> Int Int)
(i64.logic-right-shift 32))
(def: low
(-> Int Int)
(let [mask (dec (i64.left-shift 32 1))]
(|>> (i64.and mask))))
(def: #export (int value)
(-> Int (Operation Expression))
(/////wrap (//runtime.i64//new (|> value ..high _.i32)
(|> value ..low _.i32))))
(def: #export frac
(-> Frac (Operation Expression))
(|>> (cond> [(f/= frac.positive-infinity)]
[(new> _.positive-infinity [])]
[(f/= frac.negative-infinity)]
[(new> _.negative-infinity [])]
[(f/= frac.not-a-number)]
[(new> _.not-a-number [])]
## else
[_.number])
/////wrap))
(def: #export text
(-> Text (Operation Expression))
(|>> _.string /////wrap))
|