add isSome/isNone; fix more formatting; fix typoes

This commit is contained in:
Rowan 2025-03-31 20:49:12 -05:00
parent 8eaf2e5dcc
commit 19826ab203

View file

@ -46,7 +46,7 @@ const twelve = curriedAdd(4, 4, 4) // 12
``` ```
### Option ### Option
> Option<T> = Some<T> | None > Option\<T\> = Some\<T\> | None
Represents a value which may not exist. Represents a value which may not exist.
@ -120,11 +120,26 @@ none.fold((acc, x) => x, 2) // 2
##### isSome :: Option f => () -> boolean ##### isSome :: Option f => () -> boolean
> Option\<T\>.isSome() -> boolean > Option\<T\>.isSome() -> boolean
Returns a boolean based on whether the Option is `Some<T>`
```js
Some(1).isSome() // true
None.isSome() // false
```
##### isNone :: Option f => () -> boolean ##### isNone :: Option f => () -> boolean
> Option\<T\>.isNone() -> boolean > Option\<T\>.isNone() -> boolean
Returns a boolean based on whether the Option is `None`
```js
Some(1).isNone() // false
None.isNone() // true
```
### Result ### Result
> Result<T, E> = Ok<T> | Err<E> > Result<T, E> = Ok\<T\> | Err\<E\>
Represents a value which may fail. Represents a value which may fail.
@ -225,11 +240,11 @@ err.bimap(
##### isOk :: Result f => () -> boolean ##### isOk :: Result f => () -> boolean
> Result\<T, E\>.isOk() -> boolean > Result\<T, E\>.isOk() -> boolean
Returns a boolean based on whether the Result is `Some<T>` Returns a boolean based on whether the Result is `Ok<T>`
```js ```js
Ok(1).isSome() // true Ok(1).isOk() // true
Err(1).isSome() // false Err(1).isOk() // false
``` ```
##### isErr :: Result f => () -> boolean ##### isErr :: Result f => () -> boolean