Maybe.map(a => Maybe<b>, Maybe<a>):Maybe<Maybe<b>>
- Dominant language
- JavaScript
- Stars
- 5
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
Got this report in my email:
> Hi,
>
> I found your lib `maybe.flow` which looks pretty interesting.
> I am new to flow and I would like not to write tons of checks when I have many optional properties:
>```js
> if (someObj) {
> const { someKey } = someObj;
> if (someKey) { ....
> }
> ```
>
> I found that I can use your `map` for that checks though It doesn't work as I expected. Can I do something like that (the failing case): https://pastebin.com/YH5L8jaw
>
> Thank you for help and time
Inline code from https://pastebin.com/YH5L8jaw inline below for convenience
```js
import * as Maybe from './maybe';
type Params = {
age: number
};
type User = {
name: string,
params: Maybe.Maybe
};
const user: User = { name: 'Soname', params: { age: 99 } };
const params = Maybe.map(v => v.params, Maybe.just(user));
const error = Maybe.map(v => v.age, params); // Fails
const ok = Maybe.map(v => (v ? v.age : v), params);
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.