|
5495 | 5495 | "`ignore(string)` ignores the provided string and returns unit.\n\n This helper is useful when you want to discard a value (for example, the result of an operation with side effects)\n without having to store or process it further."
|
5496 | 5496 | ],
|
5497 | 5497 | "signature": "let ignore: string => unit"
|
| 5498 | + }, |
| 5499 | + { |
| 5500 | + "id": "Stdlib.String.getSymbolUnsafe", |
| 5501 | + "kind": "value", |
| 5502 | + "name": "getSymbolUnsafe", |
| 5503 | + "docstrings": [ |
| 5504 | + "`getSymbolUnsafe(str, symbol)` returns the value of the symbol property of a string.\n\n## Examples\n\n```rescript\nlet it: Iterator.t<string> = (\"foo\"->String.getSymbolUnsafe(Symbol.iterator))()\nNullable.make(it)->Nullable.isNullable == false\n```" |
| 5505 | + ], |
| 5506 | + "signature": "let getSymbolUnsafe: (string, Symbol.t) => 'a" |
5498 | 5507 | }
|
5499 | 5508 | ]
|
5500 | 5509 | },
|
|
5536 | 5545 | "kind": "value",
|
5537 | 5546 | "name": "mapOr",
|
5538 | 5547 | "docstrings": [
|
5539 |
| - "`mapOr(res, default, f)`: When res is `Ok(n)`, returns `f(n)`, otherwise `default`.\n\n## Examples\n\n```rescript\nlet ok = Ok(42)\nResult.mapOr(ok, 0, (x) => x / 2) == 21\n\nlet error = Error(\"Invalid data\")\nResult.mapOr(error, 0, (x) => x / 2) == 0\n```" |
| 5548 | + "`mapOr(res, default, f)`: When res is `Ok(n)`, returns `f(n)`, otherwise `default`.\n\n## Examples\n\n```rescript\nlet ok = Ok(42)\nResult.mapOr(ok, 0, x => x / 2) == 21\n\nlet error = Error(\"Invalid data\")\nResult.mapOr(error, 0, x => x / 2) == 0\n```" |
5540 | 5549 | ],
|
5541 | 5550 | "signature": "let mapOr: (result<'a, 'c>, 'b, 'a => 'b) => 'b"
|
5542 | 5551 | },
|
|
5553 | 5562 | "kind": "value",
|
5554 | 5563 | "name": "map",
|
5555 | 5564 | "docstrings": [
|
5556 |
| - "`map(res, f)`: When res is `Ok(n)`, returns `Ok(f(n))`. Otherwise returns res\nunchanged. Function `f` takes a value of the same type as `n` and returns an\nordinary value.\n\n## Examples\n\n```rescript\nlet f = (x) => sqrt(Int.toFloat(x))\n\nResult.map(Ok(64), f) == Ok(8.0)\n\nResult.map(Error(\"Invalid data\"), f) == Error(\"Invalid data\")\n```" |
| 5565 | + "`map(res, f)`: When res is `Ok(n)`, returns `Ok(f(n))`. Otherwise returns res\nunchanged. Function `f` takes a value of the same type as `n` and returns an\nordinary value.\n\n## Examples\n\n```rescript\nlet f = x => sqrt(Int.toFloat(x))\n\nResult.map(Ok(64), f) == Ok(8.0)\n\nResult.map(Error(\"Invalid data\"), f) == Error(\"Invalid data\")\n```" |
5557 | 5566 | ],
|
5558 | 5567 | "signature": "let map: (result<'a, 'c>, 'a => 'b) => result<'b, 'c>"
|
5559 | 5568 | },
|
|
5562 | 5571 | "kind": "value",
|
5563 | 5572 | "name": "flatMap",
|
5564 | 5573 | "docstrings": [
|
5565 |
| - "`flatMap(res, f)`: When res is `Ok(n)`, returns `f(n)`. Otherwise, returns res\nunchanged. Function `f` takes a value of the same type as `n` and returns a\n`Result`.\n\n## Examples\n\n```rescript\nlet recip = (x) =>\n if (x !== 0.0) {\n Ok(1.0 /. x)\n } else {\n Error(\"Divide by zero\")\n }\n\nResult.flatMap(Ok(2.0), recip) == Ok(0.5)\n\nResult.flatMap(Ok(0.0), recip) == Error(\"Divide by zero\")\n\nResult.flatMap(Error(\"Already bad\"), recip) == Error(\"Already bad\")\n```" |
| 5574 | + "`flatMap(res, f)`: When res is `Ok(n)`, returns `f(n)`. Otherwise, returns res\nunchanged. Function `f` takes a value of the same type as `n` and returns a\n`Result`.\n\n## Examples\n\n```rescript\nlet recip = x =>\n if x !== 0.0 {\n Ok(1.0 /. x)\n } else {\n Error(\"Divide by zero\")\n }\n\nResult.flatMap(Ok(2.0), recip) == Ok(0.5)\n\nResult.flatMap(Ok(0.0), recip) == Error(\"Divide by zero\")\n\nResult.flatMap(Error(\"Already bad\"), recip) == Error(\"Already bad\")\n```" |
5566 | 5575 | ],
|
5567 | 5576 | "signature": "let flatMap: (result<'a, 'c>, 'a => result<'b, 'c>) => result<'b, 'c>"
|
5568 | 5577 | },
|
|
5615 | 5624 | "kind": "value",
|
5616 | 5625 | "name": "compare",
|
5617 | 5626 | "docstrings": [
|
5618 |
| - "`compare(res1, res2, f)`: Compare two `Result` variables with respect to a\ncomparison function. The comparison function returns -1. if the first variable\nis \"less than\" the second, 0. if the two variables are equal, and 1. if the first\nis \"greater than\" the second.\n\nIf `res1` and `res2` are of the form `Ok(n)` and `Ok(m)`, return the result of\n`f(n, m)`. If `res1` is of the form `Error(e)` and `res2` of the form `Ok(n)`,\nreturn -1. (nothing is less than something) If `res1` is of the form `Ok(n)` and\n`res2` of the form `Error(e)`, return 1. (something is greater than nothing) If\nboth `res1` and `res2` are of the form `Error(e)`, return 0. (equal)\n\n## Examples\n\n```rescript\nlet good1 = Ok(59)\n\nlet good2 = Ok(37)\n\nlet bad1 = Error(\"invalid\")\n\nlet bad2 = Error(\"really invalid\")\n\nlet mod10cmp = (a, b) => Int.compare(mod(a, 10), mod(b, 10))\n\nResult.compare(Ok(39), Ok(57), mod10cmp) == 1.\n\nResult.compare(Ok(57), Ok(39), mod10cmp) == (-1.)\n\nResult.compare(Ok(39), Error(\"y\"), mod10cmp) == 1.\n\nResult.compare(Error(\"x\"), Ok(57), mod10cmp) == (-1.)\n\nResult.compare(Error(\"x\"), Error(\"y\"), mod10cmp) == 0.\n```" |
| 5627 | + "`compare(res1, res2, f)`: Compare two `Result` variables with respect to a\ncomparison function. The comparison function returns -1. if the first variable\nis \"less than\" the second, 0. if the two variables are equal, and 1. if the first\nis \"greater than\" the second.\n\nIf `res1` and `res2` are of the form `Ok(n)` and `Ok(m)`, return the result of\n`f(n, m)`. If `res1` is of the form `Error(e)` and `res2` of the form `Ok(n)`,\nreturn -1. (nothing is less than something) If `res1` is of the form `Ok(n)` and\n`res2` of the form `Error(e)`, return 1. (something is greater than nothing) If\nboth `res1` and `res2` are of the form `Error(e)`, return 0. (equal)\n\n## Examples\n\n```rescript\nlet good1 = Ok(59)\n\nlet good2 = Ok(37)\n\nlet bad1 = Error(\"invalid\")\n\nlet bad2 = Error(\"really invalid\")\n\nlet mod10cmp = (a, b) => Int.compare(mod(a, 10), mod(b, 10))\n\nResult.compare(Ok(39), Ok(57), mod10cmp) == 1.\n\nResult.compare(Ok(57), Ok(39), mod10cmp) == -1.\n\nResult.compare(Ok(39), Error(\"y\"), mod10cmp) == 1.\n\nResult.compare(Error(\"x\"), Ok(57), mod10cmp) == -1.\n\nResult.compare(Error(\"x\"), Error(\"y\"), mod10cmp) == 0.\n```" |
5619 | 5628 | ],
|
5620 | 5629 | "signature": "let compare: (\n result<'a, 'c>,\n result<'b, 'd>,\n ('a, 'b) => Ordering.t,\n) => Ordering.t"
|
5621 | 5630 | },
|
|
0 commit comments