Skip to content

Commit 90483c8

Browse files
committed
refactor(option): consistent variable naming in implementation
1 parent 2c1d16b commit 90483c8

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

src/Core__Option.mjs

+7-7
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ function forEach(opt, f) {
2626

2727
}
2828

29-
function getExn(x) {
30-
if (x !== undefined) {
31-
return Caml_option.valFromOption(x);
29+
function getExn(opt) {
30+
if (opt !== undefined) {
31+
return Caml_option.valFromOption(opt);
3232
}
3333
throw {
3434
RE_EXN_ID: "Not_found",
@@ -88,12 +88,12 @@ function orElse(opt, other) {
8888
}
8989
}
9090

91-
function isSome(x) {
92-
return x !== undefined;
91+
function isSome(opt) {
92+
return opt !== undefined;
9393
}
9494

95-
function isNone(x) {
96-
return x === undefined;
95+
function isNone(value) {
96+
return value === undefined;
9797
}
9898

9999
function eq(a, b, f) {

src/Core__Option.res

+17-17
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,23 @@ let flat = opt =>
3030

3131
let filterU = (opt, p) =>
3232
switch opt {
33-
| Some(x) as some if p(. x) => some
33+
| Some(value) as some if p(. value) => some
3434
| _ => None
3535
}
3636

37-
let filter = (opt, p) => filterU(opt, (. x) => p(x))
37+
let filter = (opt, p) => filterU(opt, (. value) => p(value))
3838

3939
let forEachU = (opt, f) =>
4040
switch opt {
41-
| Some(x) => f(. x)
41+
| Some(value) => f(. value)
4242
| None => ()
4343
}
4444

45-
let forEach = (opt, f) => forEachU(opt, (. x) => f(x))
45+
let forEach = (opt, f) => forEachU(opt, (. value) => f(value))
4646

47-
let getExn = x =>
48-
switch x {
49-
| Some(x) => x
47+
let getExn = opt =>
48+
switch opt {
49+
| Some(value) => value
5050
| None => raise(Not_found)
5151
}
5252

@@ -60,31 +60,31 @@ external getUnsafe: option<'a> => 'a = "%identity"
6060

6161
let mapWithDefaultU = (opt, default, f) =>
6262
switch opt {
63-
| Some(x) => f(. x)
63+
| Some(value) => f(. value)
6464
| None => default
6565
}
6666

67-
let mapWithDefault = (opt, default, f) => mapWithDefaultU(opt, default, (. x) => f(x))
67+
let mapWithDefault = (opt, default, f) => mapWithDefaultU(opt, default, (. value) => f(value))
6868

6969
let mapU = (opt, f) =>
7070
switch opt {
71-
| Some(x) => Some(f(. x))
71+
| Some(value) => Some(f(. value))
7272
| None => None
7373
}
7474

75-
let map = (opt, f) => mapU(opt, (. x) => f(x))
75+
let map = (opt, f) => mapU(opt, (. value) => f(value))
7676

7777
let flatMapU = (opt, f) =>
7878
switch opt {
79-
| Some(x) => f(. x)
79+
| Some(value) => f(. value)
8080
| None => None
8181
}
8282

83-
let flatMap = (opt, f) => flatMapU(opt, (. x) => f(x))
83+
let flatMap = (opt, f) => flatMapU(opt, (. value) => f(value))
8484

8585
let getWithDefault = (opt, default) =>
8686
switch opt {
87-
| Some(x) => x
87+
| Some(value) => value
8888
| None => default
8989
}
9090

@@ -94,13 +94,13 @@ let orElse = (opt, other) =>
9494
| None => other
9595
}
9696

97-
let isSome = x =>
98-
switch x {
97+
let isSome = opt =>
98+
switch opt {
9999
| Some(_) => true
100100
| None => false
101101
}
102102

103-
let isNone = x => x == None
103+
let isNone = value => value == None
104104

105105
let eqU = (a, b, f) =>
106106
switch a {

0 commit comments

Comments
 (0)