0 | module Node.Internal.Support
 1 |
 2 | %export "javascript:_maybe"
 3 | %foreign """
 4 |   javascript:lambda:
 5 |   ({h, a1}) => h === undefined ? a1 : undefined
 6 |   """
 7 | maybe : Maybe a -> AnyPtr
 8 |
 9 | %export "javascript:_just"
10 | %foreign """
11 |   javascript:lambda:
12 |   (a) => ({a1:a})
13 |   """
14 | just : a -> Maybe a
15 |
16 | %export "javascript:_nothing"
17 | %foreign """
18 |   javascript:lambda:
19 |   () => ({h:0})
20 |   """
21 | nothing : () -> Maybe a
22 |
23 | %export "javascript:_bool"
24 | %foreign """
25 |   javascript:lambda:
26 |   (b) => b != 0
27 |   """
28 | bool : Bool -> AnyPtr
29 |
30 | %export "javascript:_maybeBool"
31 | %foreign """
32 |   javascript:lambda:
33 |   (b) => b !== undefined ? b != 0 : undefined
34 |   """
35 | maybeBool : AnyPtr -> AnyPtr
36 |
37 | %export "javascript:_true"
38 | %foreign """
39 |   javascript:lambda:
40 |   () => 1
41 |   """
42 | true : () -> Bool
43 |
44 | %export "javascript:_false"
45 | %foreign """
46 |   javascript:lambda:
47 |   () => 0
48 |   """
49 | false : () -> Bool
50 |
51 | %export "javascript:_left"
52 | %foreign """
53 |   javascript:lambda:
54 |   (a) => ({h:0,a1:a})
55 |   """
56 | left : a -> Either a b
57 |
58 | %export "javascript:_right"
59 | %foreign """
60 |   javascript:lambda:
61 |   (a) => ({h:1,a1:a})
62 |   """
63 | right : a -> Either b a
64 |
65 | %export "javascript:_keepDefined"
66 | %foreign """
67 |   javascript:lambda:
68 |   (o) => {
69 |     const obj = {...o}
70 |     Object.keys(obj).forEach(key => obj[key] === undefined && delete obj[key])
71 |     return obj
72 |   }
73 |   """
74 | keepDefined : AnyPtr -> AnyPtr
75 |
76 |