Skip to content

Commit b054aac

Browse files
Add Bool module
1 parent 22642ea commit b054aac

File tree

3 files changed

+111
-0
lines changed

3 files changed

+111
-0
lines changed

src/Core__Bool.mjs

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Generated by ReScript, PLEASE EDIT WITH CARE
2+
3+
4+
function fromStringExn(param) {
5+
switch (param) {
6+
case "false" :
7+
return false;
8+
case "true" :
9+
return true;
10+
default:
11+
throw {
12+
RE_EXN_ID: "Invalid_argument",
13+
_1: "Bool.fromStringExn: value is neither \"true\" nor \"false\"",
14+
Error: new Error()
15+
};
16+
}
17+
}
18+
19+
function fromString(param) {
20+
switch (param) {
21+
case "false" :
22+
return false;
23+
case "true" :
24+
return true;
25+
default:
26+
return ;
27+
}
28+
}
29+
30+
function xor(a, b) {
31+
return a !== b;
32+
}
33+
34+
function xnor(a, b) {
35+
return a === b;
36+
}
37+
38+
function nand(a, b) {
39+
return !(a && b);
40+
}
41+
42+
function nor(a, b) {
43+
return !(a || b);
44+
}
45+
46+
export {
47+
fromStringExn ,
48+
fromString ,
49+
xnor ,
50+
xor ,
51+
nand ,
52+
nor ,
53+
}
54+
/* No side effect */

src/Core__Bool.res

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Core__Bool.res
2+
external compare: (bool, bool) => Core__Ordering.t = "%compare"
3+
4+
external equal: (bool, bool) => bool = "%equal"
5+
6+
@send external toString: bool => string = "toString"
7+
8+
let fromStringExn = param =>
9+
switch param {
10+
| "true" => true
11+
| "false" => false
12+
| _ => raise(Invalid_argument(`Bool.fromStringExn: value is neither "true" nor "false"`))
13+
}
14+
15+
let fromString = param =>
16+
switch param {
17+
| "true" => Some(true)
18+
| "false" => Some(false)
19+
| _ => None
20+
}
21+
22+
external and_: (bool, bool) => bool = "%sequand"
23+
24+
external or: (bool, bool) => bool = "%sequor"
25+
26+
external not: bool => bool = "%boolnot"
27+
28+
let xor = (a, b) => a !== b
29+
30+
let xnor = (a, b) => !xor(a, b)
31+
32+
let nand = (a, b) => !and_(a, b)
33+
34+
let nor = (a, b) => !or(a, b)

src/Core__Bool.resi

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
external compare: (bool, bool) => Core__Ordering.t = "%compare"
2+
3+
external equal: (bool, bool) => bool = "%equal"
4+
5+
@send external toString: bool => string = "toString"
6+
7+
let fromStringExn: string => bool
8+
9+
let fromString: string => option<bool>
10+
11+
external and_: (bool, bool) => bool = "%sequand"
12+
13+
external or: (bool, bool) => bool = "%sequor"
14+
15+
external not: bool => bool = "%boolnot"
16+
17+
let xnor: (bool, bool) => bool
18+
19+
let xor: (bool, bool) => bool
20+
21+
let nand: (bool, bool) => bool
22+
23+
let nor: (bool, bool) => bool

0 commit comments

Comments
 (0)