-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathCore__Result.mjs
115 lines (104 loc) · 1.89 KB
/
Core__Result.mjs
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Generated by ReScript, PLEASE EDIT WITH CARE
import * as Curry from "rescript/lib/es6/curry.js";
import * as Core__Error from "./Core__Error.mjs";
function getExn(x) {
if (x.TAG === /* Ok */0) {
return x._0;
} else {
return Core__Error.panic("Result.getExn: result is Error");
}
}
function mapWithDefault(opt, $$default, f) {
var f$1 = Curry.__1(f);
if (opt.TAG === /* Ok */0) {
return f$1(opt._0);
} else {
return $$default;
}
}
function map(opt, f) {
var f$1 = Curry.__1(f);
if (opt.TAG === /* Ok */0) {
return {
TAG: /* Ok */0,
_0: f$1(opt._0)
};
} else {
return {
TAG: /* Error */1,
_0: opt._0
};
}
}
function flatMap(opt, f) {
var f$1 = Curry.__1(f);
if (opt.TAG === /* Ok */0) {
return f$1(opt._0);
} else {
return {
TAG: /* Error */1,
_0: opt._0
};
}
}
function getWithDefault(opt, $$default) {
if (opt.TAG === /* Ok */0) {
return opt._0;
} else {
return $$default;
}
}
function isOk(x) {
if (x.TAG === /* Ok */0) {
return true;
} else {
return false;
}
}
function isError(x) {
if (x.TAG === /* Ok */0) {
return false;
} else {
return true;
}
}
function eq(a, b, f) {
var f$1 = Curry.__2(f);
if (a.TAG === /* Ok */0) {
if (b.TAG === /* Ok */0) {
return f$1(a._0, b._0);
} else {
return false;
}
} else if (b.TAG === /* Ok */0) {
return false;
} else {
return true;
}
}
function cmp(a, b, f) {
var f$1 = Curry.__2(f);
if (a.TAG === /* Ok */0) {
if (b.TAG === /* Ok */0) {
return f$1(a._0, b._0);
} else {
return 1;
}
} else if (b.TAG === /* Ok */0) {
return -1;
} else {
return 0;
}
}
export {
getExn ,
mapWithDefault ,
map ,
flatMap ,
getWithDefault ,
isOk ,
isError ,
eq ,
cmp ,
}
/* No side effect */