Skip to content

Commit 35ff35a

Browse files
committed
Further improve docs
1 parent 24e35a8 commit 35ff35a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

DOCS.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3377,8 +3377,11 @@ safe_call(might_raise_IOError).expect_error(IOError).result_or(10)
33773377

33783378
To match against an `Expected`, just:
33793379
```
3380-
Expected(res) = Expected("result")
3381-
Expected(error=err) = Expected(error=TypeError())
3380+
match some_expected:
3381+
case Expected(res):
3382+
print("result:", res)
3383+
case Expected(error=err):
3384+
print("error:", err)
33823385
```
33833386

33843387
##### Example
@@ -3406,7 +3409,7 @@ Additionally, if you are using [view patterns](#match), you might need to raise
34063409

34073410
In some cases where there are multiple Coconut packages installed at the same time, there may be multiple `MatchError`s defined in different packages. Coconut can perform some magic under the hood to make sure that all these `MatchError`s will seamlessly interoperate, but only if all such packages are compiled in [`--package` mode rather than `--standalone` mode](#compilation-modes).
34083411

3409-
### `CoconutWarning`
3412+
#### `CoconutWarning`
34103413

34113414
`CoconutWarning` is the [`Warning`](https://docs.python.org/3/library/exceptions.html#Warning) subclass used for all runtime Coconut warnings; see [`warnings`](https://docs.python.org/3/library/warnings.html).
34123415

@@ -3464,13 +3467,13 @@ In Haskell, `fmap(func, obj)` takes a data type `obj` and returns a new data typ
34643467

34653468
For `dict`, or any other `collections.abc.Mapping`, `fmap` will map over the mapping's `.items()` instead of the default iteration through its `.keys()`, with the new mapping reconstructed from the mapped over items. _Deprecated: `fmap$(starmap_over_mappings=True)` will `starmap` over the `.items()` instead of `map` over them._
34663469

3467-
For asynchronous iterables, `fmap` will map asynchronously, making `fmap` equivalent in that case to
3470+
For asynchronous iterables, `fmap` is equivalent to
34683471
```coconut_python
34693472
async def fmap_over_async_iters(func, async_iter):
34703473
async for item in async_iter:
34713474
yield func(item)
34723475
```
3473-
such that `fmap` can effectively be used as an async map.
3476+
which allows mapping a synchronous function over an asynchronous iterable. To map an asynchronous function over a synchronous iterable, see [`async_map`](#async_map).
34743477

34753478
Some objects from external libraries are also given special support:
34763479
* For [`numpy`](#numpy-integration) objects, `fmap` will use [`np.vectorize`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.vectorize.html) to produce the result.
@@ -3527,7 +3530,7 @@ def safe_call(f, /, *args, **kwargs):
35273530
return Expected(error=err)
35283531
```
35293532

3530-
To define a function that always returns an `Expected` rather than raising any errors, simply decorate it with `@safe_call$`.
3533+
To define a function that always returns an `Expected` rather than raising any `Exception`s, simply decorate it with `@safe_call$`.
35313534

35323535
##### Example
35333536

0 commit comments

Comments
 (0)