Skip to content

Commit 362d3a3

Browse files
committed
Adapt docs in belt_Option.mli for parts missing in rescript-lang.org MDX
1 parent 646081f commit 362d3a3

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

jscomp/others/belt_Option.mli

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,12 @@ val keepU : 'a option -> ('a -> bool [@bs]) -> 'a option
4444

4545
val keep : 'a option -> ('a -> bool) -> 'a option
4646
(**
47-
`keep optionValue p`
47+
If `optionValue` is `Some(value)` and `p(value) = true`, it returns `Some(value)`; otherwise returns `None`
4848
49-
If `optionValue` is `Some value` and `p value = true`, it returns `Some value`; otherwise returns `None`
50-
51-
```
52-
keep (Some 10)(fun x -> x > 5);; (* returns `Some 10` *)
53-
keep (Some 4)(fun x -> x > 5);; (* returns `None` *)
54-
keep None (fun x -> x > 5);; (* returns `None` *)
49+
```res example
50+
Belt.Option.keep(Some(10), x => x > 5) /* returns `Some(10)` */
51+
Belt.Option.keep(Some(4), x => x > 5) /* returns `None` */
52+
Belt.Option.keep(None, x => x > 5) /* returns `None` */
5553
```
5654
*)
5755

@@ -60,13 +58,11 @@ val forEachU : 'a option -> ('a -> unit [@bs]) -> unit
6058

6159
val forEach : 'a option -> ('a -> unit) -> unit
6260
(**
63-
`forEach optionValue f`
64-
65-
If `optionValue` is `Some value`, it calls `f value`; otherwise returns `()`
61+
If `optionValue` is `Some(value`), it calls `f(value)`; otherwise returns `()`
6662
67-
```
68-
forEach (Some "thing")(fun x -> Js.log x);; (* logs "thing" *)
69-
forEach None (fun x -> Js.log x);; (* returns () *)
63+
```res example
64+
Belt.Option.forEach(Some("thing"), x => Js.log(x)) /* logs "thing" */
65+
Belt.Option.forEach(None, x => Js.log(x)) /* returns () */
7066
```
7167
*)
7268

@@ -83,9 +79,11 @@ val getExn : 'a option -> 'a
8379

8480
external getUnsafe :
8581
'a option -> 'a = "%identity"
86-
(** `getUnsafe x` returns x
87-
This is an unsafe operation, it assumes x is neither not None
88-
or (Some (None .. ))
82+
(**
83+
`getUnsafe(x)` returns `x`
84+
85+
This is an unsafe operation, it assumes `x` is neither `None`
86+
nor `Some(None(...)))`
8987
*)
9088

9189
val mapWithDefaultU : 'a option -> 'b -> ('a -> 'b [@bs]) -> 'b

0 commit comments

Comments
 (0)