Skip to content

docs(option): fixes for several docstrings #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/Core__Option.resi
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Option.forEach(None, x => Console.log(x)) // returns ()
let forEach: (option<'a>, 'a => unit) => unit

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

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

/**
`mapWithDefault(opt, default, f)` applies `f` to `opt`, if `opt` is `None`, then
`f` return `default`, otherwise return that value applied with `f`.
`mapWithDefault(opt, default, f)` returns `Some(f(value))` if `opt` is `Some(value)`, otherwise `default`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be "... returns f(value)"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah it should be. Good catch! Fixed in #70


## Examples

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

/**
`map(opt f)` applies `f` to `opt`, if `opt` is `Some(value)` this returns
`f(value)`, otherwise it returns `None`.
`map(opt, f)` returns `Some(f(value))` if `opt` is `Some(value)`, otherwise `None`.

## Examples

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

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

## Examples

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

/**
`getWithDefault(opt, default)` returns `value` if `opt` is `Some(value)`,
otherwise return `default` if `opt` is `None`.
`getWithDefault(opt, default)` returns `value` if `opt` is `Some(value)`, otherwise `default`.

## Examples

Expand Down