You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"documentation": {"kind": "markdown", "value": "\n Converts a given `float` to a `string`. Uses the JavaScript `String` constructor under the hood.\n\n ```res example\n Js.log(Belt.Float.toString(1.0) === \"1.0\") /* true */\n ```\n"}
1739
1739
}]
1740
1740
1741
-
Complete src/Completion.res 425:7
1742
-
posCursor:[425:7] posNoWhite:[425:6] Found expr:[425:3->0:-1]
1743
-
Completable: Cpath Value[ok]->
1741
+
Complete src/Completion.res 425:8
1742
+
posCursor:[425:8] posNoWhite:[425:7] Found expr:[425:3->425:8]
1743
+
Completable: Cpath Value[ok]->g
1744
1744
Raw opens: 2 Shadow.B.place holder ... Shadow.A.place holder
"documentation": {"kind": "markdown", "value": "\n `map(res, f)`: When res is `Ok(n)`, returns `Ok(f(n))`. Otherwise returns res\n unchanged. Function `f` takes a value of the same type as `n` and returns an\n ordinary value.\n\n ```res example\n let f = (x) => sqrt(Belt.Int.toFloat(x))\n\n Belt.Result.map(Ok(64), f) == Ok(8.0)\n\n Belt.Result.map(Error(\"Invalid data\"), f) == Error(\"Invalid data\")\n ```\n"}
1770
-
}, {
1771
1747
"label": "Belt.Result.getExn",
1772
1748
"kind": 12,
1773
1749
"tags": [],
1774
1750
"detail": "t<'a, 'b> => 'a",
1775
1751
"documentation": {"kind": "markdown", "value": "\n `getExn(res)`: when `res` is `Ok(n)`, returns `n` when `res` is `Error(m)`, raise an exception\n\n ```res example\n Belt.Result.getExn(Belt.Result.Ok(42)) == 42\n\n Belt.Result.getExn(Belt.Result.Error(\"Invalid data\")) /* raises exception */\n ```\n"}
1776
-
}, {
1777
-
"label": "Belt.Result.mapWithDefault",
1778
-
"kind": 12,
1779
-
"tags": [],
1780
-
"detail": "(t<'a, 'c>, 'b, 'a => 'b) => 'b",
1781
-
"documentation": {"kind": "markdown", "value": "\n `mapWithDefault(res, default, f)`: When res is `Ok(n)`, returns `f(n)`,\n otherwise `default`.\n\n ```res example\n let ok = Belt.Result.Ok(42)\n Belt.Result.mapWithDefault(ok, 0, (x) => x / 2) == 21\n\n let error = Belt.Result.Error(\"Invalid data\")\n Belt.Result.mapWithDefault(error, 0, (x) => x / 2) == 0\n ```\n"}
"documentation": {"kind": "markdown", "value": "\n `isError(res)`: Returns `true` if `res` is of the form `Error(e)`, `false` if\n it is the `Ok(n)` variant.\n"}
"detail": "(t<'a, 'c>, 'a => t<'b, 'c>) => t<'b, 'c>",
1805
-
"documentation": {"kind": "markdown", "value": "\n `flatMap(res, f)`: When res is `Ok(n)`, returns `f(n)`. Otherwise, returns res\n unchanged. Function `f` takes a value of the same type as `n` and returns a\n `Belt.Result`.\n\n ```res example\n let recip = (x) =>\n if (x !== 0.0) {\n Belt.Result.Ok(1.0 /. x)\n } else {\n Belt.Result.Error(\"Divide by zero\")\n }\n\n Belt.Result.flatMap(Ok(2.0), recip) == Ok(0.5)\n\n Belt.Result.flatMap(Ok(0.0), recip) == Error(\"Divide by zero\")\n\n Belt.Result.flatMap(Error(\"Already bad\"), recip) == Error(\"Already bad\")\n ```\n"}
"documentation": {"kind": "markdown", "value": "\n `eq(res1, res2, f)`: Determine if two `Belt.Result` variables are equal with\n respect to an equality function. If `res1` and `res2` are of the form `Ok(n)`\n and `Ok(m)`, return the result of `f(n, m)`. If one of `res1` and `res2` are of\n the form `Error(e)`, return false If both `res1` and `res2` are of the form\n `Error(e)`, return true\n\n ```res example\n let good1 = Belt.Result.Ok(42)\n\n let good2 = Belt.Result.Ok(32)\n\n let bad1 = Belt.Result.Error(\"invalid\")\n\n let bad2 = Belt.Result.Error(\"really invalid\")\n\n let mod10equal = (a, b) => mod(a, 10) === mod(b, 10)\n\n Belt.Result.eq(good1, good2, mod10equal) == true\n\n Belt.Result.eq(good1, bad1, mod10equal) == false\n\n Belt.Result.eq(bad2, good2, mod10equal) == false\n\n Belt.Result.eq(bad1, bad2, mod10equal) == true\n ```\n"}
"documentation": {"kind": "markdown", "value": "\n `isOk(res)`: Returns `true` if `res` is of the form `Ok(n)`, `false` if it is\n the `Error(e)` variant.\n"}
"documentation": {"kind": "markdown", "value": "\n `cmp(res1, res2, f)`: Compare two `Belt.Result` variables with respect to a\n comparison function. The comparison function returns -1 if the first variable\n is \"less than\" the second, 0 if the two variables are equal, and 1 if the first\n is \"greater than\" the second.\n\n If `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)`,\n return -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\n both `res1` and `res2` are of the form `Error(e)`, return 0 (equal)\n\n ```res example\n let good1 = Belt.Result.Ok(59)\n\n let good2 = Belt.Result.Ok(37)\n\n let bad1 = Belt.Result.Error(\"invalid\")\n\n let bad2 = Belt.Result.Error(\"really invalid\")\n\n let mod10cmp = (a, b) => Pervasives.compare(mod(a, 10), mod(b, 10))\n\n Belt.Result.cmp(Ok(39), Ok(57), mod10cmp) == 1\n\n Belt.Result.cmp(Ok(57), Ok(39), mod10cmp) == (-1)\n\n Belt.Result.cmp(Ok(39), Error(\"y\"), mod10cmp) == 1\n\n Belt.Result.cmp(Error(\"x\"), Ok(57), mod10cmp) == (-1)\n\n Belt.Result.cmp(Error(\"x\"), Error(\"y\"), mod10cmp) == 0\n ```\n"}
0 commit comments