@@ -172,11 +172,11 @@ let isOk: result<'a, 'b> => bool
172
172
let isError : result <'a , 'b > => bool
173
173
174
174
/**
175
- `equal(res1, res2, f )`: Determine if two `Result` variables are equal with
176
- respect to an equality function . If `res1` and `res2` are of the form `Ok(n)`
177
- and `Ok(m)`, return the result of `f (n, m)`. If one of `res1` and `res2` are of
175
+ `equal(res1, res2, fOk, fError )`: Determine if two `Result` variables are equal with
176
+ respect to equality functions . If `res1` and `res2` are of the form `Ok(n)`
177
+ and `Ok(m)`, return the result of `fOk (n, m)`. If one of `res1` and `res2` are of
178
178
the form `Error(e)`, return false If both `res1` and `res2` are of the form
179
- `Error(e)`, return true
179
+ `Error(e)`, return the result of `fError(e1, e2)`.
180
180
181
181
## Examples
182
182
@@ -191,28 +191,28 @@ let bad2 = Error("really invalid")
191
191
192
192
let mod10equal = (a, b) => mod(a, 10) === mod(b, 10)
193
193
194
- Result.equal(good1, good2, mod10equal) == true
194
+ Result.equal(good1, good2, mod10equal, String.equal ) == true
195
195
196
- Result.equal(good1, bad1, mod10equal) == false
196
+ Result.equal(good1, bad1, mod10equal, String.equal ) == false
197
197
198
- Result.equal(bad2, good2, mod10equal) == false
198
+ Result.equal(bad2, good2, mod10equal, String.equal ) == false
199
199
200
- Result.equal(bad1, bad2, mod10equal) == true
200
+ Result.equal(bad1, bad2, mod10equal, String.equal ) == false
201
201
```
202
202
*/
203
- let equal : (result <'a , 'c >, result <'b , 'd >, ('a , 'b ) => bool ) => bool
203
+ let equal : (result <'a , 'c >, result <'b , 'd >, ('a , 'b ) => bool , ( 'c , 'd ) => bool ) => bool
204
204
205
205
/**
206
- `compare(res1, res2, f )`: Compare two `Result` variables with respect to a
206
+ `compare(res1, res2, fOk, fError )`: Compare two `Result` variables with respect to a
207
207
comparison function. The comparison function returns -1. if the first variable
208
208
is "less than" the second, 0. if the two variables are equal, and 1. if the first
209
209
is "greater than" the second.
210
210
211
211
If `res1` and `res2` are of the form `Ok(n)` and `Ok(m)`, return the result of
212
- `f (n, m)`. If `res1` is of the form `Error(e)` and `res2` of the form `Ok(n)`,
212
+ `fOk (n, m)`. If `res1` is of the form `Error(e)` and `res2` of the form `Ok(n)`,
213
213
return -1. (nothing is less than something) If `res1` is of the form `Ok(n)` and
214
- `res2` of the form `Error(e)`, return 1. (something is greater than nothing) If
215
- both `res1` and `res2` are of the form `Error(e)`, return 0. (equal)
214
+ `res2` is of the form `Error(e)`, return 1. (something is greater than nothing) If
215
+ both `res1` and `res2` are of the form `Error(e)`, return fError(e1, e2).
216
216
217
217
## Examples
218
218
@@ -227,18 +227,23 @@ let bad2 = Error("really invalid")
227
227
228
228
let mod10cmp = (a, b) => Int.compare(mod(a, 10), mod(b, 10))
229
229
230
- Result.compare(Ok(39), Ok(57), mod10cmp) == 1.
230
+ Result.compare(Ok(39), Ok(57), mod10cmp, String.compare ) == 1.
231
231
232
- Result.compare(Ok(57), Ok(39), mod10cmp) == -1.
232
+ Result.compare(Ok(57), Ok(39), mod10cmp, String.compare ) == -1.
233
233
234
- Result.compare(Ok(39), Error("y"), mod10cmp) == 1.
234
+ Result.compare(Ok(39), Error("y"), mod10cmp, String.compare ) == 1.
235
235
236
- Result.compare(Error("x"), Ok(57), mod10cmp) == -1.
236
+ Result.compare(Error("x"), Ok(57), mod10cmp, String.compare ) == -1.
237
237
238
- Result.compare(Error("x"), Error("y"), mod10cmp) == 0 .
238
+ Result.compare(Error("x"), Error("y"), mod10cmp, String.compare ) == -1 .
239
239
```
240
240
*/
241
- let compare : (result <'a , 'c >, result <'b , 'd >, ('a , 'b ) => Stdlib_Ordering .t ) => Stdlib_Ordering .t
241
+ let compare : (
242
+ result <'a , 'c >,
243
+ result <'b , 'd >,
244
+ ('a , 'b ) => Stdlib_Ordering .t ,
245
+ ('c , 'd ) => Stdlib_Ordering .t ,
246
+ ) => Stdlib_Ordering .t
242
247
243
248
/**
244
249
`forEach(res, f)` runs the provided function `f` on the `Ok` value. If `res` is `Error`, nothing happens.
0 commit comments