@@ -172,11 +172,11 @@ let isOk: result<'a, 'b> => bool
172172let isError : result <'a , 'b > => bool
173173
174174/**
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, eqOk, eqError )`: 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 `eqOk (n, m)`. If one of `res1` and `res2` are of
178178the 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 `eqError(e1, e2)`.
180180
181181## Examples
182182
@@ -191,28 +191,28 @@ let bad2 = Error("really invalid")
191191
192192let mod10equal = (a, b) => mod(a, 10) === mod(b, 10)
193193
194- Result.equal(good1, good2, mod10equal) == true
194+ Result.equal(good1, good2, mod10equal, String.equal ) == true
195195
196- Result.equal(good1, bad1, mod10equal) == false
196+ Result.equal(good1, bad1, mod10equal, String.equal ) == false
197197
198- Result.equal(bad2, good2, mod10equal) == false
198+ Result.equal(bad2, good2, mod10equal, String.equal ) == false
199199
200- Result.equal(bad1, bad2, mod10equal) == true
200+ Result.equal(bad1, bad2, mod10equal, String.equal ) == false
201201```
202202*/
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
204204
205205/**
206- `compare(res1, res2, f )`: Compare two `Result` variables with respect to a
206+ `compare(res1, res2, cmpOk, cmpError )`: Compare two `Result` variables with respect to a
207207comparison function. The comparison function returns -1. if the first variable
208208is "less than" the second, 0. if the two variables are equal, and 1. if the first
209209is "greater than" the second.
210210
211211If `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+ `cmpOk (n, m)`. If `res1` is of the form `Error(e)` and `res2` of the form `Ok(n)`,
213213return -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 cmpError(e1, e2).
216216
217217## Examples
218218
@@ -227,18 +227,23 @@ let bad2 = Error("really invalid")
227227
228228let mod10cmp = (a, b) => Int.compare(mod(a, 10), mod(b, 10))
229229
230- Result.compare(Ok(39), Ok(57), mod10cmp) == 1.
230+ Result.compare(Ok(39), Ok(57), mod10cmp, String.compare ) == 1.
231231
232- Result.compare(Ok(57), Ok(39), mod10cmp) == -1.
232+ Result.compare(Ok(57), Ok(39), mod10cmp, String.compare ) == -1.
233233
234- Result.compare(Ok(39), Error("y"), mod10cmp) == 1.
234+ Result.compare(Ok(39), Error("y"), mod10cmp, String.compare ) == 1.
235235
236- Result.compare(Error("x"), Ok(57), mod10cmp) == -1.
236+ Result.compare(Error("x"), Ok(57), mod10cmp, String.compare ) == -1.
237237
238- Result.compare(Error("x"), Error("y"), mod10cmp) == 0 .
238+ Result.compare(Error("x"), Error("y"), mod10cmp, String.compare ) == -1 .
239239```
240240*/
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
242247
243248/**
244249`forEach(res, f)` runs the provided function `f` on the `Ok` value. If `res` is `Error`, nothing happens.
0 commit comments