-
Notifications
You must be signed in to change notification settings - Fork 1
/
Lets.re
58 lines (50 loc) · 857 Bytes
/
Lets.re
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
54
55
56
57
module Guard = {
let let_ = ((condition, default), continuation) => if (condition) {
continuation()
} else {
default
}
};
module OptDefault = {
let let_ = ((a, default), b) => switch (a) {
| None => default
| Some(x) => b(x)
};
let or_ = (v, default) => {
switch v {
| None => default
| Some(c) => c
}
}
};
module Opt = {
let let_ = (a, b) => switch (a) {
| None => None
| Some(x) => b(x)
}
};
module OptIf = {
let let_ = (a, b) => if (a) {
b()
} else {
None
}
};
module OptMap = {
let let_ = (a, b) => switch (a) {
| None => None
| Some(x) => Some(b(x))
}
};
module OptOr = {
let let_ = (a, b) => switch (a) {
| None => b()
| Some(x) => a
}
};
module OptConsume = {
let let_ = (a, b) => switch (a) {
| None => ()
| Some(x) => b(x)
}
};