Skip to content

Commit 2093988

Browse files
authored
docs(option): fixes for several docstrings (#68)
1 parent 64f449d commit 2093988

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/Core__Option.resi

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Option.forEach(None, x => Console.log(x)) // returns ()
6666
let forEach: (option<'a>, 'a => unit) => unit
6767

6868
/**
69-
`getExn(opt)` raises an Error in case `None` is provided.
69+
`getExn(opt)` returns `value` if `opt` is `Some(value)`, otherwise raises an exception.
7070

7171
```rescript
7272
Option.getExn(Some(3)) // 3
@@ -96,8 +96,7 @@ Option.getUnsafe(None) // Raises an error
9696
external getUnsafe: option<'a> => 'a = "%identity"
9797

9898
/**
99-
`mapWithDefault(opt, default, f)` applies `f` to `opt`, if `opt` is `None`, then
100-
`f` return `default`, otherwise return that value applied with `f`.
99+
`mapWithDefault(opt, default, f)` returns `Some(f(value))` if `opt` is `Some(value)`, otherwise `default`.
101100

102101
## Examples
103102

@@ -112,8 +111,7 @@ noneValue->Option.mapWithDefault(0, x => x + 5) // 0
112111
let mapWithDefault: (option<'a>, 'b, 'a => 'b) => 'b
113112

114113
/**
115-
`map(opt f)` applies `f` to `opt`, if `opt` is `Some(value)` this returns
116-
`f(value)`, otherwise it returns `None`.
114+
`map(opt, f)` returns `Some(f(value))` if `opt` is `Some(value)`, otherwise `None`.
117115

118116
## Examples
119117

@@ -125,8 +123,7 @@ Option.map(None, x => x * x) // None
125123
let map: (option<'a>, 'a => 'b) => option<'b>
126124

127125
/**
128-
`flatMap(opt, f)` returns `f` applied to `opt` if `opt` is `Some(value)`,
129-
otherwise `None`. The function `f` must have a return type of `option<'b>`.
126+
`flatMap(opt, f)` returns `f(value)` if `opt` is `Some(value)`, otherwise `None`.
130127

131128
## Examples
132129

@@ -146,8 +143,7 @@ Option.flatMap(None, addIfAboveOne) // None
146143
let flatMap: (option<'a>, 'a => option<'b>) => option<'b>
147144

148145
/**
149-
`getWithDefault(opt, default)` returns `value` if `opt` is `Some(value)`,
150-
otherwise return `default` if `opt` is `None`.
146+
`getWithDefault(opt, default)` returns `value` if `opt` is `Some(value)`, otherwise `default`.
151147

152148
## Examples
153149

0 commit comments

Comments
 (0)